internal static PizzaOrder Map(OrderClass order, Dictionary <int, string> IngrediantDictionary)
        {
            PizzaOrder ret = new PizzaOrder
            {
                StoreId           = order.Store.StoreID,
                CustomerId        = order.Customer.UserID,
                CustomerAddressId = order.DeliveryAddress.AddressID
            };

            foreach (PizzaClass zaa in order.pizzas)
            {
                if (ret.PizzasInOrder.Where(PiO => PiO.PizzaId == zaa.PizzaID).Count() == 0)
                {
                    ret.PizzasInOrder.Add(new PizzasInOrder
                    {
                        PizzaId      = zaa.PizzaID,
                        PizzaOrderId = ret.StoreId,
                        Quantity     = 1
                    });
                }
                else
                {
                    ret.PizzasInOrder.First(PiO => PiO.PizzaId == zaa.PizzaID).Quantity++;
                }
            }
            return(ret);
        }
        public void PlaceOrder(OrderClass order)
        {
            Dictionary <int, string> dict = GenerateIngrediantDictionary();

            foreach (var zaa in order.pizzas)
            {
                zaa.PizzaID = GetPizzaID(zaa.Ingrediants, zaa.Size);
            }
            PizzaOrder newOrder = Map(order, dict);

            newOrder.PizzaOrderId = _db.PizzaOrder.Max(po => po.PizzaOrderId) + 1;

            _db.Add(newOrder);
            Save();
        }
        internal static OrderClass Map(PizzaOrder order, CustomerClass customer, StoreClass store)
        {
            OrderClass ret = new OrderClass
            {
                Store           = store,
                Customer        = customer,
                DeliveryAddress = Map(order.CustomerAddress),
                OrderID         = order.PizzaOrderId,
                DatePlaced      = order.DatePlaced,
            };

            foreach (var PiO in order.PizzasInOrder)
            {
                ret.pizzas.Add(Map(PiO.Pizza));
            }

            ret.UpdateTotal();

            return(ret);
        }