public void ChooseActionForItems() { ItemDal itemDal = new ItemDal(); Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("What action you want to choose?\n" + "1. View all items\n" + "2. Get item by Id\n" + "3. Get item by name of column\n" + "4. Add item\n" + "5. Edit info about item\n" + "6. Delete item by Id\n" + "7. Delete item by name of column\n" + "8. Back to start menu"); Console.Write("\nYour selection: "); string ch = Console.ReadLine(); switch (ch) { case "1": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); itemDal.PrintListOfItems(itemDal.GetAll()); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "2": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nId: "); int id = Convert.ToInt32(Console.ReadLine()); itemDal.PrintItem(itemDal.GetById(id)); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "3": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nName of column: "); string fieldName = Console.ReadLine(); Console.WriteLine("\nValue: "); string text = Console.ReadLine(); itemDal.PrintListOfItems(itemDal.GetByFieldName(fieldName, text)); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "4": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("NAME: "); string name = Console.ReadLine(); Console.WriteLine("DESCRIPTION: "); string desc = Console.ReadLine(); Console.WriteLine("CATEGORY_ID: "); int categId = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("PRICE: "); decimal price = Convert.ToDecimal(Console.ReadLine()); Console.WriteLine("IN_STOCK: "); string inStock = Console.ReadLine(); Item item = new Item(name, desc, categId, price, inStock); itemDal.Insert(item); Console.WriteLine("Item succesfully inserted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "5": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n"); Console.WriteLine("Name of column (set): "); string fieldName = Console.ReadLine(); Console.WriteLine("Value (set): "); string text = Console.ReadLine(); Console.WriteLine("Name of column (condition): "); string fieldCondition = Console.ReadLine(); Console.WriteLine("Value (condition): "); string textCondition = Console.ReadLine(); itemDal.UpdateByFieldName(fieldName, text, fieldCondition, textCondition); Console.WriteLine("Item succesfully updated :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "6": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\nId: "); int id = Convert.ToInt32(Console.ReadLine()); itemDal.DeleteById(id); Console.WriteLine("Item succesfully deleted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "7": { try { Console.Clear(); Console.WriteLine("TABLE: ITEMS\n\n "); Console.WriteLine("Name of column (condition): "); string fieldCondition = Console.ReadLine(); Console.WriteLine("Value (condition): "); string textCondition = Console.ReadLine(); itemDal.DeleteByFieldName(fieldCondition, textCondition); Console.WriteLine("Item succesfully deleted :)"); Console.ReadKey(); break; } finally { Menu menu = new Menu(); menu.ChooseActionForItems(); } } case "8": { Menu menu = new Menu(); menu.ChooseTable(); break; } default: Console.WriteLine("Invalid selection. Please select 1, 2, 3, 4, 5, 6, 7 or 8."); break; } }