Esempio n. 1
0
 public CheckoutOutput(CustomerOutput customer, BasketOutput basket, DateTime orderDate, double totalPrice)
 {
     Customer   = customer;
     Basket     = basket;
     OrderDate  = orderDate;
     TotalPrice = totalPrice;
 }
Esempio n. 2
0
        public async Task Process(GetBasketDetailsInput input)
        {
            var basket = await basketReadOnlyRepository.Get(input.BasketId);

            if (basket == null)
            {
                outputBoundary.Populate(null);
                return;
            }

            BasketOutput output = outputConverter.Map <BasketOutput>(basket);

            outputBoundary.Populate(output);
        }
Esempio n. 3
0
        public async Task Process(AddBasketInput input)
        {
            Customer customer = await customerReadOnlyRepository.Get(input.CustomerId);

            if (customer == null)
            {
                throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exist or it was not processed yet.");
            }

            Basket basket = new Basket(customer.Id);

            await basketWriteOnlyRepository.Add(basket);

            CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer);
            BasketOutput   basketOutput   = outputConverter.Map <BasketOutput>(basket);

            AddBasketOutput output = new AddBasketOutput(customerOutput, basketOutput);

            outputBoundary.Populate(output);
        }
Esempio n. 4
0
        public async Task Process(CheckoutInput input)
        {
            Customer customer = await customerReadOnlyRepository.Get(input.CustomerId);

            if (customer == null)
            {
                throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exist or it was not processed yet.");
            }

            Basket basket = await basketReadOnlyRepository.Get(input.BasketId);

            if (basket == null)
            {
                throw new BasketNotFoundException($"The basket {input.BasketId} does not exist or it was already deleted.");
            }

            CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer);
            BasketOutput   basketOutput   = outputConverter.Map <BasketOutput>(basket);

            CheckoutOutput output = new CheckoutOutput(customerOutput, basketOutput, input.OrderDate, basket.GetTotalPrice().Value);

            outputBoundary.Populate(output);
        }
Esempio n. 5
0
 public AddBasketOutput(CustomerOutput customer, BasketOutput basket)
 {
     Customer = customer;
     Basket   = basket;
 }