Esempio n. 1
0
        public static void PlaceOrder()
        {
            ProductHandler.PrintProductTypes();
            Console.WriteLine("Fill the information below about the order:");
            string ID     = ProductHandler.ValidatedID();
            int    amount = 0;

            bool validUserInput = false;

            while (validUserInput == false)
            {
                try
                {
                    Console.Write("Enter the amount of products to order: ");
                    amount         = int.Parse(Console.ReadLine()); // now bh = employee`s body heat
                    validUserInput = true;
                }
                catch
                {
                    Console.Clear();
                    Console.WriteLine("Wrong input!"); Console.WriteLine();
                }
            }
            ProductType pt = ProductHandler.GetProductTypeByID(ID);

            if (pt is null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Product not found");
                Console.ForegroundColor = ConsoleColor.White;
                return;
            }
            Random rand    = new Random();
            int    orderID = rand.Next(1, 999);

            Console.Clear();
            Console.WriteLine(); Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"Order placed! Your order ID is: {orderID}");
            Console.ForegroundColor = ConsoleColor.White;
            ProductOrder PO_temp = new ProductOrder(pt, amount, orderID.ToString());

            Inventory.Instance.AddOrderToDB(PO_temp);
        }
Esempio n. 2
0
        public static void AddToInventory(string ProductTypeID, int Amount)
        {
            ProductType pt = ProductHandler.GetProductTypeByID(ProductTypeID);

            Inventory.Instance.AddToInventory(pt, Amount);
        }