public OrderProductDeleteCommandValidation(IBasketDbContext context, IUserContextManager userContextManager, IProductsClient productsClient) { RuleFor(x => x.OrderId).NotEmpty(); RuleFor(x => x.OrderId).OrderExists(context, userContextManager); RuleFor(x => x.ProductId).NotEmpty(); RuleFor(x => x.ProductId).ProductExists(productsClient); }
public OrderViewQueryHandler(IBasketDbContext context, IMapper mapper, IUserContextManager userContextManager, IProductsClient productsClient) { _context = context; _mapper = mapper; _userContextManager = userContextManager; _productsClient = productsClient; }
public OrderProductUpdateCommandValidation(IBasketDbContext context, IUserContextManager userContextManager, IProductsClient productsClient) { _context = context; _userContextManager = userContextManager; RuleFor(x => x.OrderId).NotEmpty(); RuleFor(x => x.OrderId).OrderExists(context, userContextManager); RuleFor(x => x.ProductId).NotEmpty(); RuleFor(x => x.ProductId).ProductExists(productsClient); RuleFor(x => x.Quantity).NotEmpty(); RuleFor(x => x).MustAsync(ProductInOrderAsync).WithErrorCode("ProductNotInOrder"); }
public OrderUpdateCommandValidator(IBasketDbContext context, IUserContextManager userContextManager) { RuleFor(x => x.OrderId).NotEmpty(); RuleFor(x => x.Status).IsInEnum(); RuleFor(x => x.OrderId).OrderExists(context, userContextManager); }
public OrderCreateCommandHandler(IBasketDbContext context, IUserContextManager userContextManager) { _context = context; _userContextManager = userContextManager; }
public static IRuleBuilderOptions <T, Guid> OrderExists <T>(this IRuleBuilderInitial <T, Guid> builder, IBasketDbContext context, IUserContextManager userContextManager) { return(builder.MustAsync(async(Guid orderId, CancellationToken cancellationToken) => { var customerEmail = userContextManager.GetCurrentUserEmail(); var order = await context.Orders.FirstOrDefaultAsync(x => x.Id == orderId && x.CustomerEmail == customerEmail, cancellationToken); return order != null; }).WithErrorCode("OrderNotExists")); }
public OrdersViewQueryHandler(IBasketDbContext context, IMapper mapper, IUserContextManager userContextManager) { _context = context; _mapper = mapper; _userContextManager = userContextManager; }