-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug with validation for SchedulesEvents #880
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that my comment is a blocker to merge, but I advise you to check it and maybe change it
{ | ||
if (await _unitOfWork.ScheduledEventRepository.IsLessonConnectedToSheduledEventAsync(lessonId)) | ||
string errorMsg = await _validator.ValidateConnectEventToLessonAsync(eventId, lessonId); | ||
|
||
if (!string.IsNullOrEmpty(errorMsg)) | ||
{ | ||
return Result<ScheduledEventDTO>.GetError(ErrorCode.Conflict, $"Lesson with id={lessonId} is already associated with another ScheduledEvent"); | ||
throw new EntityValidationException(errorMsg); | ||
} | ||
|
||
var scheduleEntity = await _unitOfWork.ScheduledEventRepository.ConnectEventToLessonByIdAsync(eventId, lessonId); | ||
|
||
return scheduleEntity == null ? | ||
Result<ScheduledEventDTO>.GetError(ErrorCode.NotFound, $"Scheduled event with id={eventId} does not exist") : | ||
Result<ScheduledEventDTO>.GetSuccess(_mapper.Map<ScheduledEventDTO>(scheduleEntity)); | ||
return Result<ScheduledEventDTO>.GetSuccess(_mapper.Map<ScheduledEventDTO>(scheduleEntity)); | ||
} | ||
|
||
public async Task<Result<SingleEventDTO>> CreateSingleEventAsync(CreateSingleEventDto createSingleEvent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to use Result instead of throwing an exception, u sure that we need to throw an exception? It`s an additional performance issue, logging this exception and other effects
# Conflicts: # CharlieBackend.Business/Helpers/ResponseMessages.cs # CharlieBackend.Business/Services/ScheduleServiceFolder/EventsService.cs
No description provided.