public OrderController()
 {
     CustomerRepository = new CustomerRepository();
     InventoryRepository = new InventoryRepository();
     OrderRepository = new OrderRepository();
     EmailLibrary = new EmailLibrary();
 }
 public OrderController(
     CustomerRepository customerRepository,
     OrderRepository orderRepository,
     InventoryRepository inventoryRepository,
     EmailLibrary emailLibrary)
 {
     CustomerRepository = customerRepository;
     OrderRepository = orderRepository;
     InventoryRepository = inventoryRepository;
     EmailLibrary = emailLibrary;
 }
Beispiel #3
0
        public void PlaceOrder(
            Customer customer,
            Order order,
            Payment payment,
            bool allowSplitOrders,
            bool emailReceipt)
        {
            CustomerRepository.Add(customer);

            OrderRepository.Add(order);

            InventoryRepository.OrderItems(order, allowSplitOrders);

            payment.ProcessPayment();

            if (emailReceipt)
            {
                customer.ValidateEmail();
                CustomerRepository.Update();

                EmailLibrary.SendEmail(customer.EmailAddress, "Here's the receipt");
            }
        }