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");
        }
Exemple #2
0
 public UpdateCourseCommandHandler(ICourseRepositoryAsync courseRepositoryAsync)
 {
     _courseRepositoryAsync = courseRepositoryAsync;
 }
 public GetCourseByIdQueryHandler(IMapper mapper, ICourseRepositoryAsync courseRepositoryAsync)
 {
     _mapper = mapper;
     _courseRepositoryAsync = courseRepositoryAsync;
 }
 public CreateCourseCommandHandler(IMapper mapper, ICourseRepositoryAsync courseRepositoryAsync)
 {
     _mapper = mapper;
     _courseRepositoryAsync = courseRepositoryAsync;
 }
Exemple #5
0
 public DeleteCourseByIdCommandHandler(ICourseRepositoryAsync courseRepositoryAsync)
 {
     _courseRepositoryAsync = courseRepositoryAsync;
 }