Exemple #1
0
        public int CreateOrder(Order order, ShoppingCart shopingCart)
        {
            var cartItems = cartProcessingService.GetCartItems(shopingCart);

            foreach (var item in cartItems)
            {
                var pizzaToOrder = new PizzaToOrder
                {
                    PizzaId   = item.PizzaId,
                    OrderId   = order.Id,
                    Quantity  = item.Count,
                    UnitPrice = (item.Count * item.Pizza.Price)
                };
                db.PizzasToOrder.Add(pizzaToOrder);
            }

            db.SaveChanges();
            orderProcessingService.EmptyCart(shopingCart);
            return(order.Id);
        }