public OrderSummary PlaceOrder(Order order)
        {
            List<OrderItem> orderItems = order.OrderItems;
            Customer customer = RetrieveCustomer(order.CustomerId);

            if (OrderIsValid(order, orderItems))
            {
                OrderConfirmation orderConfirmation =_orderFulfillmentService.Fulfill(order);

                IEnumerable<TaxEntry> applicableTaxes = RetrieveTaxEntries(customer).ToList();
                decimal netTotal = CalculateNetTotal(order);
                decimal orderTotal = CalculateOrderTotal(netTotal, applicableTaxes);

                OrderSummary orderSummary= new OrderSummary
                {
                    OrderNumber = orderConfirmation.OrderNumber,
                    OrderId = orderConfirmation.OrderId,
                    CustomerId = orderConfirmation.CustomerId,
                    Taxes = applicableTaxes,
                    NetTotal = netTotal,
                    Total = orderTotal,
                };

                _emailService.SendOrderConfirmationEmail(orderSummary.CustomerId, orderSummary.OrderId);
                return orderSummary;
            }
            else
                throw new Exception(_reasonsForInvalidOrder);
        }
        public OrderSummary PlaceOrder(Order order)
        {
            ValidateOrder(order);

            var fulfillment = _orderFulfillmentService.Fulfill(order);

            var customer = _customerRepository.Get(order.CustomerId);

            var netTotal = CalculateNetTotal(order);

            var listOfTaxEntries = CreateListOfTaxEntries(customer);

            var orderTotal = CalculateOrderTotal(listOfTaxEntries, netTotal);

            var orderSummary = new OrderSummary()
            {
                OrderNumber = fulfillment.OrderNumber,
                OrderId = fulfillment.OrderId,
                Taxes = listOfTaxEntries,
                NetTotal = netTotal,
                Total = orderTotal
            };

            SendConfirmationEmail(order, orderSummary);

            return orderSummary;
        }
 private void SendConfirmationEmail(Order order, OrderSummary orderSummary)
 {
     _emailService.SendOrderConfirmationEmail(order.CustomerId, orderSummary.OrderId);
 }