public CarStockCommandFunctionality(IUnitOfWork unitOfWork, IMapperFactory mapperFactory, IGenericWriteRepository writeRepository, IValidatorFactory validatorFactory, IFileManager fileManager, IGenericReadRepository readRepository, ICarPhotoFiltersProvider carPhotoFiltersProvider, ICarStockFiltersProvider carStockFiltersProvider, ICarStockCommandRepository carStockCommandRepository) : base(unitOfWork, mapperFactory, writeRepository, validatorFactory) { _fileManager = fileManager; _readRepository = readRepository; _carPhotoFiltersProvider = carPhotoFiltersProvider; _carStockFiltersProvider = carStockFiltersProvider; _carStockCommandRepository = carStockCommandRepository; }
public OrderFromStockCreateCommandValidator(IGenericReadRepository readRepository, IValidator <OrderWithDeliveryRequestCreateCommand> validator, ICarStockFiltersProvider carStockFiltersProvider) : base(readRepository) { _carStockFiltersProvider = carStockFiltersProvider; RuleFor(x => x) .SetValidator(validator) .MustAsync(CarAmountIsValid) .WithMessage("There are not enough cars in stock to create an order."); }
public DeliveryRequestCreateCommandValidator(IGenericReadRepository readRepository, ICarStockFiltersProvider carStockFiltersProvider, IUserFiltersProvider userFiltersProvider) : base(readRepository) { _carStockFiltersProvider = carStockFiltersProvider; _userFiltersProvider = userFiltersProvider; RuleFor(x => x.CarId) .NotEmptyWithMessage() .MustExistsWithMessageAsync(CarExists); RuleFor(x => x.ManagerId) .NotEmptyWithMessage() .MustExistsWithMessageAsync(ManagerIsValid); RuleFor(x => x.Amount) .IsPositiveWithMessage(); }
public CarStockUpdateCommandValidator(IGenericReadRepository readRepository, IModelSupportsBodyTypeFiltersProvider modelBodyTypeFiltersProvider, ICarModelFiltersProvider modelFiltersProvider, IModelSupportsColorFiltersProvider modelColorFiltersProvider, ICarComplectationFiltersProvider complectationFiltersProvider, IEngineSupportsGearboxFiltersProvider engineGearboxFiltersProvider, ICarStockFiltersProvider carStockFiltersProvider) : base(readRepository) { _modelBodyTypeFiltersProvider = modelBodyTypeFiltersProvider; _modelFiltersProvider = modelFiltersProvider; _modelColorFiltersProvider = modelColorFiltersProvider; _complectationFiltersProvider = complectationFiltersProvider; _engineGearboxFiltersProvider = engineGearboxFiltersProvider; _carStockFiltersProvider = carStockFiltersProvider; RuleFor(x => x.Id) .NotEmptyWithMessage() .MustExistsWithMessageAsync(CarExists); RuleFor(x => x.ModelId) .NotEmptyWithMessage() .MustExistsWithMessageAsync(ModelExists) .DependentRules(() => { RuleFor(x => x.BodyTypeId) .NotEmptyWithMessage() .MustAsync(BodyTypeIsValid) .WithMessage($"The {{PropertyName}} is not compatible with the provided model."); RuleFor(x => x.ColorId) .NotEmptyWithMessage() .MustAsync(ColorIsValid) .WithMessage($"The {{PropertyName}} is not compatible with the provided model."); RuleFor(x => x.EngineGearboxId) .NotEmptyWithMessage() .MustAsync(EngineGearboxIsValid) .WithMessage($"The {{PropertyName}} is not compatible with the provided model."); RuleFor(x => x.ComplectationId) .NotEmptyWithMessage() .MustAsync(ComplectationIsValid) .WithMessage($"The {{PropertyName}} is not compatible with the provided model."); }); RuleFor(x => x.Amount) .IsPositiveOrZeroWithMessage(); RuleFor(x => x.Price) .IsPositiveOrZeroWithMessage(); }