public RestoreRecipeValidator(IAggregatesRepository <Recipe> repository) { _repository = repository; RuleFor(x => x.EntityId) .NotEmpty() .MustAsync(DoesExist).WithMessage("Provided EntityId must not exist."); }
public GetRecipeByIdValidator(IAggregatesRepository <Recipe> repository) { _repository = repository; RuleFor(x => x.Id) .NotEmpty() .MustAsync(Exist); }
public DeleteRecipeValidator(IAggregatesRepository <Recipe> repository, ICurrentUserService currentUserService) { _repository = repository; _currentUserService = currentUserService; RuleFor(x => x.EntityId) .NotEmpty() .MustAsync(Exist).WithMessage("Provided EntityId must already exist.") .MustAsync(MustBeCreatedByGivenUser).WithMessage("Provided Entity must be created by authenticated user."); }
public UpdateRecipeValidator(IAggregatesRepository <Recipe> repository, ICurrentUserService currentUserService) { _repository = repository; _currentUserService = currentUserService; RuleFor(x => x.EntityId) .NotEmpty() .MustAsync(Exist).WithMessage("Provided EntityId must already exist.") .MustAsync(MustBeCreatedByGivenUser).WithMessage("Provided Entity must be created by authenticated user."); RuleFor(x => x.Name) .NotEmpty() .MaximumLength(256) .Must(IsDefaultString).WithMessage("Name must not be a placeholder."); RuleFor(x => x.Description) .NotEmpty() .MaximumLength(3072) .Must(IsDefaultString).WithMessage("Description must not be a placeholder."); RuleFor(x => x.PictureUrl) .MaximumLength(2048) .Must(IsValidUrl).WithMessage("PictureUrl must be a valid PictureUrl"); RuleFor(x => x.Calories) .NotEmpty(); RuleFor(x => x.Ingredients) .NotEmpty(); RuleForEach(x => x.Ingredients) .NotEmpty() .MaximumLength(256) .Must(IsDefaultString).WithMessage("Ingredients[] must not be a placeholder."); RuleFor(x => x.Steps) .NotEmpty(); RuleForEach(x => x.Steps) .NotEmpty() .MaximumLength(3072) .Must(IsDefaultString).WithMessage("Ingredients[] must not be a placeholder."); RuleFor(x => x.MealTypes) .NotEmpty(); }
public GetRecipesHandler(IAggregatesRepository <Recipe> repository) { _repository = repository; _random = new Random(); }
public GetUserRecipesHandler(IAggregatesRepository <Recipe> repository) { _repository = repository; }
public GetRecipeByIdHandler(IAggregatesRepository <Recipe> repository) { _repository = repository; }