public CreateTimetableCommandValidator(ICourseRepositoryAsync courseRepositoryAsync, ITimetableRespositoryAsync timetableRespositoryAsync) { _courseRepositoryAsync = courseRepositoryAsync; _timetableRespositoryAsync = timetableRespositoryAsync; RuleFor(e => e.CourseId) .NotEmpty().WithMessage("Field '{PropertyName}' not be empty") .MustAsync(ExistsCourseAsync).WithMessage("Field '{PropertyName}' Course not found") .MustAsync(CourseUsedInTimetableAsync).WithMessage("Course already added") .WithName("courseId"); RuleFor(e => e.DayOfWeek) .Must(ValidationRangeDayOfWeek).WithMessage("Field '{PropertyName}' has incorrect value") .Must(ValidationDayOfWeek).WithMessage("Field '{PropertyName}' must not be 'Saturday' or 'Sunday'") .WithName("dayOfWeek"); RuleFor(e => e.StartCourse) .NotNull().WithMessage("Field '{PropertyName}' not be empty") .NotEmpty().WithMessage("Field '{PropertyName}' not be empty") .Must(TryParseTime).WithMessage("Field '{PropertyName}' incorrect format. Example '12:00:00'") .Must(ValidationOfСourseTime).WithMessage("Field '{PropertyName}' time must be greater 09:00:00 and less 17:00:00") .WithName("startCourse"); RuleFor(e => e.EndCourse) .NotNull().WithMessage("Field '{PropertyName}' not be empty") .NotEmpty().WithMessage("Field '{PropertyName}' not be empty") .Must(TryParseTime).WithMessage("Field '{PropertyName}' incorrect format. Example '12:00:00'") .Must(ValidationOfСourseTime).WithMessage("Field '{PropertyName}' time must be greater 09:00:00 and less 17:00:00") .WithName("endCourse"); }
public GetAllTimetablesQueryHandler(IMapper mapper, ITimetableRespositoryAsync timetableRespositoryAsync) { _mapper = mapper; _timetableRespositoryAsync = timetableRespositoryAsync; }
public CreateTimetableCommandHandler(IMapper mapper, ITimetableRespositoryAsync timetableRespositoryAsync) { _mapper = mapper; _timetableRespositoryAsync = timetableRespositoryAsync; }