public OrderValidator(IProductCommandRepository productRepository, IServiceMethodCommandRepository serviceMethodRepository) { _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); _serviceMethodRepository = serviceMethodRepository ?? throw new ArgumentNullException(nameof(serviceMethodRepository)); RuleFor(itm => itm).MustAsync(async(o, cancellation) => await ProductExists(o.ProductId).ConfigureAwait(false)).WithMessage(ErrorMessages.OrderedProductDoesNotExist); RuleFor(itm => itm).MustAsync(async(o, cancellation) => await ProductAvailable(o.ProductId).ConfigureAwait(false)) .When(itm => ProductExists(itm.ProductId).Result == true).WithMessage(ErrorMessages.OrdredProductIsNotAvailable); RuleFor(itm => itm).MustAsync(async(o, cancellation) => await ServiceMethodExists(o.ServiceMethodId).ConfigureAwait(false)).WithMessage(ErrorMessages.OrderedServiceMethodDoesNotExist); }
public PlaceOrdersCommandValidator(IProductCommandRepository productRepository, IServiceMethodCommandRepository serviceMethodRepository) { _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); _serviceMethodRepository = serviceMethodRepository ?? throw new ArgumentNullException(nameof(serviceMethodRepository)); RuleFor(itm => itm.CustomerDetails).NotNull().WithMessage(ErrorMessages.NoCustomerDataSupplied); RuleFor(itm => itm.CustomerDetails.Name).NotEmpty().When(itm => itm.CustomerDetails != null).WithErrorCode(ErrorMessages.NoCustomerNameSupplied); RuleForEach(itm => itm.Orders).SetValidator(new OrderValidator(_productRepository, _serviceMethodRepository)); Thread.Sleep(5000); }
public ActivateProductCommandHandler(IProductCommandRepository productRepository, ILogger logger, IEventPublisher <INotification> eventPublisher) { _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _eventPublisher = eventPublisher ?? throw new ArgumentNullException(nameof(eventPublisher)); }
public ProductCommandService(IProductCommandRepository command, IMapper mapper) : base(command, mapper) { }
public CommandUnitOfWork(EkartCommandContext context) { _context = context; ProductCommandRepository = new ProductCommandRepository(context); }
public CreateProductCommandHandler(IProductCommandRepository repository) { this.repository = repository; }
public IActionResult Post([FromServices] IProductCommandRepository productCommandRepository, [FromBody] Product product) { productCommandRepository.Add(product); return(Ok(product)); }