Пример #1
0
        public static void AddProd()
        {
            ProductsCollection productsCollection = new ProductsCollection();
            Storage            storage            = new Storage();

            while (true)
            {
                Console.Write("name ");
                string name = Console.ReadLine();
                if (name == "quit")
                {
                    break;
                }

                Console.Write("Section ");
                string       sectionStr = Console.ReadLine();
                MenuSections sections   = MenuSections.Гарниры;

                if (sectionStr == "1")
                {
                    sections = MenuSections.Первое;
                }
                else if (sectionStr == "2")
                {
                    sections = MenuSections.Гарниры;
                }
                else if (sectionStr == "3")
                {
                    sections = MenuSections.Салаты;
                }
                else if (sectionStr == "4")
                {
                    sections = MenuSections.Десерты;
                }
                else if (sectionStr == "5")
                {
                    sections = MenuSections.Напитки;
                }

                Console.Write("price ");
                double price = double.Parse(Console.ReadLine());

                productsCollection.Add(new Product(name, sections, price));
                Console.WriteLine(new String('-', 30));
            }

            foreach (Product product in productsCollection)
            {
                Console.Write(product.Name + " Quantity ");
                int quantity = int.Parse(Console.ReadLine());

                storage.Add(product.ProductId, quantity);
            }

            DataBaseController.AllProductsSave(productsCollection);
            DataBaseController.StorageBaseSave(storage);

            Console.ReadKey();
        }
Пример #2
0
        public void SendOrder(ShoppingCart cart, ref Client client)
        {
            Dictionary <int, int> productList = new Dictionary <int, int>();

            foreach (KeyValuePair <Product, int> pair in cart)
            {
                storage.Subtract(pair.Key.ProductId, pair.Value);
                productList.Add(pair.Key.ProductId, pair.Value);
            }

            Order order = new Order(client.name, client.phoneNumber, cart.GetSum(), productList);

            client.AddOrderToHistory(order);

            DataBaseController.StorageBaseSave(storage);
            DataBaseController.SendOrder(order);
        }