public CreateCountryCommandHandler( ICountryFactory countryFactory, ICountryDomainRepository countryRepository) { this.countryFactory = countryFactory; this.countryRepository = countryRepository; }
public CreateCityCommandValidator(ICountryDomainRepository repository) { this.RuleFor(cmd => cmd.Name) .MinimumLength(MinNameLength) .MaximumLength(MaxNameLength) .NotEmpty(); this.RuleFor(cmd => cmd.CountryId) .MustAsync(async(countryId, token) => await repository .Find(countryId, token) != null) .WithMessage("'{PropertyName}' does not exist."); }
public PlaceCommandValidator( IPlaceDomainRepository placeRepository, ICategoryDomainRepository categoryRepository, ICountryDomainRepository countryRepository) { CascadeMode = CascadeMode.StopOnFirstFailure; this.RuleFor(c => c.Name) .MinimumLength(MinNameLength) .MaximumLength(MaxNameLength) .NotEmpty(); this.RuleFor(c => c.Description) .MinimumLength(MinDescriptionLength) .MaximumLength(MaxDescriptionLength) .NotEmpty(); //this.RuleFor(c => c.CategoryId) // .MustAsync(async (category, token) => await categoryRepository // .Get(category, token) != null) // .WithMessage("{PropertyName} does not exist."); this.RuleFor(c => c.CountryId) .MustAsync(async(counrty, token) => await countryRepository .Find(counrty, token) != null) .WithMessage("{PropertyName} does not exist."); this.RuleFor(c => c) .Must(cmd => Enumeration.HasValue <PlaceType>(cmd.Type.Value)) .WithMessage("'PlaceType' is not valid."); this.RuleSet("Data", () => { this.RuleFor(c => c) .MustAsync(async(cmd, token) => await countryRepository .Find(cmd.CountryId, cmd.CityId, token) != null) .WithMessage("'City' does not exist."); }); }
public DeleteCountryCommandHandler(ICountryDomainRepository countryRepository) { this.countryRepository = countryRepository; }
public CreateCityCommandHandler(ICountryDomainRepository countryDomainRepository) { this.countryDomainRepository = countryDomainRepository; }