Пример #1
0
        private void SetOrder(Order newOrder)
        {
            double itemPrice = 0;

            int pizzaId  = newOrder.Items[ItemIndex][0];
            int size     = newOrder.Items[ItemIndex][1];
            int crust    = newOrder.Items[ItemIndex][2];
            int quantity = newOrder.Items[ItemIndex][3];

            if (size == Convert.ToInt32(PizzaSize.small))
            {
                itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceSmall;
            }
            else if (size == Convert.ToInt32(PizzaSize.medium))
            {
                itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceMedium;
            }
            else if (size == Convert.ToInt32(PizzaSize.large))
            {
                itemPrice = Pizza_Manager.GlobalPizzas[pizzaId].PriceLarge;
            }
            else
            {
                UserIO.PrintRed("Error");
            }

            if (crust == Convert.ToInt32(PizzaCrust.CheeseCrust))
            {
                itemPrice += 2;
            }

            itemPrice *= quantity;
            newOrder.ItemPrice.Add(itemPrice);
            newOrder.ItemPriceArray = newOrder.ItemPrice.ToArray();

            newOrder.TotalPrice += itemPrice;
            newOrder.ItemCount  += quantity;
            //newOrder.Date = Convert.ToString(DateTime.Now);
            newOrder.Date = DateTime.Now;

            int id = File_Manager.CountLinesFile(App_Constands.FilePathOrder);

            newOrder.Id = id;
        }