Пример #1
0
        public void UpdateStock()
        {
            List <Tablet> tablet = new List <Tablet>();

            tablet.Add(new Tablet(1, "citrizen", 5, 500));
            tablet.Add(new Tablet(2, "paracetamol", 10, 200));
            tablet.Add(new Tablet(3, "ativan", 7, 300));
            tablet.Add(new Tablet(4, "colpal", 8, 500));
            Tablet[] tabletInfo = TabletBLL.showTablet(tablet);
            foreach (var t in tabletInfo)
            {
                Console.WriteLine(t.ToString());
            }
            Console.WriteLine("-----------------------");
            Console.WriteLine("Enter tablet Id to update stock");
            int tId = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter stock");
            int tstock = Convert.ToInt32(Console.ReadLine());

            try
            {
                if (tstock > 0)
                {
                    string tab = TabletBLL.updateStock(tId, tstock, tablet);
                    foreach (var t in tabletInfo)
                    {
                        Console.WriteLine(t.ToString());
                    }
                }
                else
                {
                    throw (new NegativeStockException("Tablet Stock cannot be less than zero "));
                }
            }
            catch (NegativeStockException e)
            {
                Console.WriteLine(e.Message.ToString());
                Console.ReadLine();
            }
            Console.WriteLine("Please choose from below if you wish to continue with other services");
            Console.WriteLine("-----------------------");
            Console.WriteLine("1.Add tablet to stock");
            Console.WriteLine("2.update tablet stock");
            Console.WriteLine("3.view order history");
            Console.WriteLine("4.Exit");
            shopop();
        }