Beispiel #1
0
        public CreateEventCommandValidator(CleanCodeContext dbContext)
        {
            _dbContext = dbContext;

            RuleFor(x => x.Name)
            .NotEmpty().WithMessage("{PropertyName} is required")
            .NotNull()
            .MaximumLength(50).WithMessage("{PropertyName} must no exceeed 50 characters");

            RuleFor(x => x.Date)
            .NotEmpty().WithMessage("{PropertyName} is required")
            .NotNull()
            .GreaterThan(DateTime.Now);

            RuleFor(x => x)
            .MustAsync(EventNameAndDateUnique)
            .WithMessage("An event with the same name and date alread exists");

            RuleFor(x => x.Price)
            .NotEmpty().WithMessage("{PropertyName} is required")
            .GreaterThan(0);
        }
Beispiel #2
0
 public GetEventDetailQueryHandler(IMapper mapper, CleanCodeContext cleanCodeContext)
 {
     _mapper           = mapper;
     _cleanCodeContext = cleanCodeContext;
 }
Beispiel #3
0
 public CreateEventCommandHandler(IMapper mapper, CleanCodeContext cleanCodeContext)
 {
     _mapper           = mapper;
     _cleanCodeContext = cleanCodeContext;
 }
Beispiel #4
0
 public GetCategoriesListQueryHandler(IMapper mapper, CleanCodeContext dbContext)
 {
     _mapper    = mapper;
     _dbContext = dbContext;
 }