Skip to content
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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Ssashaa
Copy link
Contributor

@Ssashaa Ssashaa commented May 16, 2022

No description provided.

Copy link
Collaborator

@PavelTsyposhchuk PavelTsyposhchuk left a 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

Comment on lines 62 to 75
{
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)
Copy link
Collaborator

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

Ssashaa and others added 4 commits June 3, 2022 11:15
# Conflicts:
#	CharlieBackend.Business/Helpers/ResponseMessages.cs
#	CharlieBackend.Business/Services/ScheduleServiceFolder/EventsService.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants