コード例 #1
0
        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");
        }
コード例 #2
0
 public GetAllTimetablesQueryHandler(IMapper mapper, ITimetableRespositoryAsync timetableRespositoryAsync)
 {
     _mapper = mapper;
     _timetableRespositoryAsync = timetableRespositoryAsync;
 }
コード例 #3
0
 public CreateTimetableCommandHandler(IMapper mapper, ITimetableRespositoryAsync timetableRespositoryAsync)
 {
     _mapper = mapper;
     _timetableRespositoryAsync = timetableRespositoryAsync;
 }