public CattleValidator(ICattleService cattleService) { _cattleService = cattleService; RuleSet("CREATECATTLE", () => { RuleFor(x => x.Name) .NotNull() .Length(4, 20) .OverridePropertyName("name"); RuleFor(x => x.Name) .Must(ValidateExistName) .OverridePropertyName("name") .WithMessage("Já existe um gado cadastrado com esse nome!"); }); RuleSet("EDITCATTLE", () => { RuleFor(x => x.Name) .NotNull() .Length(4, 20) .OverridePropertyName("name"); RuleSet("name", () => { RuleFor(x => x) .Must(ValidateExistName) .OverridePropertyName("name") .WithMessage("Já existe um gado cadastrado com esse nome!"); }); }); }
public CattleController( ICattleService cattleService, IValidator <Cattle> cattleValidator, IVoteService voteService, ICattleWithVotesService cattleWithVotesService, IObjectStorageService azureBlobService ) { _cattleService = cattleService; _cattleValidator = cattleValidator; _voteService = voteService; _cattleWithVotesService = cattleWithVotesService; _objectStorageService = azureBlobService; }