public CreateCategoryCommandValidator(IXNewsDbContext context) { RuleFor(c => c.Title) .NotEmpty() .Length(CategoryValidationOptions.TitleMinLength, CategoryValidationOptions.TitleMaxLength) .UniqueInsideOfDbSetColumn(context.Category, c => c.Title); }
public Handler(IXNewsDbContext context, IMapper mapper, IIdentityStorage <ApplicationUser, string> userStorage) { _context = context; _mapper = mapper; _userStorage = userStorage; }
public DeletePostCommandValidator(IXNewsDbContext context) { _context = context; RuleFor(c => c.PostId) .NotEmpty() .MustAsync(HaveNoCommentsAsync) .WithMessage("Cannot remove post, that has comments"); }
public UpdateCategoryCommandValidator(IXNewsDbContext context) { _context = context; RuleFor(c => c.CategoryId) .NotEmpty(); RuleFor(c => c.Title) .NotEmpty() .Length(CategoryValidationOptions.TitleMinLength, CategoryValidationOptions.TitleMaxLength) .UniqueInsideOfDbSetColumn(context.Category, c => c.Title) .WhenAsync(CategoryTitleWasUpdated); }
public CreatePostCommandValidators(IXNewsDbContext context, IIdentityStorage <ApplicationUser, string> userStorage) { RuleFor(c => c.Content) .NotEmpty() .Length(PostValidationOptions.ContentMinLength, PostValidationOptions.ContentMaxLength); RuleFor(c => c.Title) .NotEmpty() .Length(PostValidationOptions.TitleMinLength, PostValidationOptions.TitleMaxLength) .UniqueInsideOfDbSetColumn(context.Post, p => p.Title); RuleFor(c => c.UserId) .NotEmpty(); }
public AddRateToCommentCommandValidator(IXNewsDbContext context) { RuleFor(c => c.CommentId) .NotEmpty(); RuleFor(c => c.Rate) .In(CommentRateValidationOptions.NegativeRate, CommentRateValidationOptions.PositiveRate); RuleFor(c => c.UserId) .NotEmpty(); RuleFor(c => new object[] { c.UserId, c.CommentId }) .UniqueForColumnsCombinationInDbSet(context.CommentRate, commentRate => new { commentRate.UserId, commentRate.CommentId }) .WithMessage("User has already rated this comment"); }
public UpdatePostCommandValidator(IXNewsDbContext context) { _context = context; RuleFor(c => c.PostId) .NotEmpty(); RuleFor(c => c.Content) .NotEmpty() .Length(PostValidationOptions.ContentMinLength, PostValidationOptions.ContentMaxLength); RuleFor(c => c.Title) .NotEmpty() .Length(PostValidationOptions.TitleMinLength, PostValidationOptions.TitleMaxLength) .UniqueInsideOfDbSetColumn(context.Post, p => p.Title) .WhenAsync(PostTitleWasUpdated); RuleFor(c => c.UserId) .NotEmpty(); }
public Handler(IMapper mapper, IXNewsDbContext context) { _mapper = mapper; _context = context; }
public Handler(IXNewsDbContext context) { _context = context; }
public Handler(IXNewsDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }