Exemple #1
0
        public async Task <bool> PurchasePhysicalProduct([FromServices] ICustomerRepository customerRepository, [FromServices] IShippingSlipRepository shippingSlipRepository, [FromServices] CreateOrderCommand createOrderCommand)
        {
            // basically preparing the data. Creating a customer and product.
            Customer cust1 = new Customer("Bartho");

            customerRepository.Add(cust1);
            await customerRepository.UnitOfWork.SaveEntitiesAsync();

            Product membership = new Product("Book", "Book", 20, ProductType.Book);

            ShoppingCartItem item = new ShoppingCartItem();

            item.Quantity = 1;
            item.Product  = membership;

            // Actual command
            var order = await createOrderCommand.Execute(cust1.Id, new List <ShoppingCartItem> {
                item
            });

            var slip = await shippingSlipRepository.FindByOrderIdAsync(order.Id);

            return(true);
        }
Exemple #2
0
 public OrderedPhysicalProductDomainEventHandler(IShippingSlipRepository shippingSlipRepository)
 {
     _shippingSlipRepository = shippingSlipRepository ?? throw new ArgumentNullException(nameof(shippingSlipRepository));
 }