Пример #1
0
 protected void ShowItems()
 {
     Console.Clear();
     Console.WriteLine("ID \tName \t Amount \t Value");
     foreach (var item in ShopDBProvider.GetInstance().GetItemsList())
     {
         Console.WriteLine("{0}. {1}\t{2}\t{3}", item.ID, item.Name, item.Amount, item.Value);
     }
     Console.WriteLine("Press enter");
     Console.ReadLine();
 }
Пример #2
0
 protected void ChangeItemValue()
 {
     Console.WriteLine("Select item");
     if (!int.TryParse(Console.ReadLine(), out int itemID))
     {
         throw new Exception("incorrect value");
     }
     Console.WriteLine("Input item value");
     if (!double.TryParse(Console.ReadLine(), out double itemValue))
     {
         throw new Exception("incorrect value");
     }
     ShopDBProvider.GetInstance().ChangePrice(itemID, itemValue);
 }
Пример #3
0
 protected void Sell()
 {
     ShowItems();
     Console.WriteLine("Select item ID to sell");
     if (!int.TryParse(Console.ReadLine(), out int itemID))
     {
         throw new Exception("incorrect value");
     }
     Console.WriteLine("Select amount to sell");
     if (!int.TryParse(Console.ReadLine(), out int itemAmount))
     {
         throw new Exception("incorrect value");
     }
     ShopDBProvider.GetInstance().SellItem(itemID, itemAmount);
 }
Пример #4
0
        protected void AddItem()
        {
            ShowItems();
            Console.WriteLine("Input item name");
            string itemName = Console.ReadLine();

            Console.WriteLine("input item price");
            if (!int.TryParse(Console.ReadLine(), out int itemAmount))
            {
                throw new Exception("incorrect value");
            }
            if (!double.TryParse(Console.ReadLine(), out double itemPrice))
            {
                throw new Exception("incorrect value");
            }
            ShopDBProvider.GetInstance().AddItem(itemName, itemAmount, itemPrice);
        }