Exemple #1
0
        /// <summary>
        /// Prints list of products.
        /// </summary>
        private static void ShowProducts()
        {
            DataBase db = DataBase.GetInstance();

            db.LoadProducts();
            List <Product> products = new List <Product>();

            products = db.Products;
            foreach (Product product in products)
            {
                Console.WriteLine(product.ToString());
            }
        }
Exemple #2
0
        private static void PerformOrder()
        {
            Order order    = new Order();
            bool  ordering = true;

            try
            {
                while (ordering)
                {
                    Console.WriteLine("Enter 1 to add new product 0 to end order:");
                    char option = Convert.ToChar(Console.ReadLine());
                    switch (option)
                    {
                    case '0':
                    {
                        ordering = false;
                        break;
                    }

                    case '1':
                    {
                        DataBase database = DataBase.Instance;
                        database.SetConnections(Constants.dataBasePath);
                        database.LoadProducts();
                        Console.WriteLine("Enter id of product:");
                        int id = Convert.ToInt32(Console.ReadLine());
                        //order.AddProduct(database.GetProductById(id),1);
                        break;
                    }

                    default:
                    {
                        throw new Exception();
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("");
            }
        }