public void AddItemToMenuShop() { string name = string.Empty; double price; string unit; bool checkInput = false; int yourChoice = -1; do { Console.Write("Please enter name of item: "); name = ValidDataServices.FormatName(Console.ReadLine()); } while (name == ""); if (!IsItemExists(name)) { do { Console.Write("Please enter item's price: "); checkInput = ConvertServices.ToDoubleByTryParse(Console.ReadLine(), out price); } while (!checkInput || price <= 0); do { Console.Write("Please enter unit type of item: "); unit = Console.ReadLine().Trim(); checkInput = ConvertServices.ToIntByTryParse(unit, out int temp); } while (unit == "" || checkInput); switch (yourChoice) { case 1: Drink newDrink = new Drink(nameInput: name, priceInput: price, unitInput: unit); _menu.ListDrinksOfShop.Add(newDrink); Console.WriteLine("Your drink item has add to Drinks Menu"); break; case 2: Food newFood = new Food(nameInput: name, priceInput: price, unitInput: unit); _menu.ListFoodsOfShop.Add(newFood); Console.WriteLine("Your food item has add to Foods Menu"); break; } FileJsonServices.WriteFileJson(_shopUseServices, FilePath.StrDataFileFullPath); } else { Console.WriteLine($"Shop have item with name {name}, please change another name"); } }
public bool InputDataOrder(out int id, out int qty, out int tableNumber) { id = -1; qty = -1; tableNumber = -1; bool checkInput = false; Console.WriteLine("Enter 0 to cancel"); do { Console.Write("Please enter id of item: "); checkInput = ConvertServices.ToIntByTryParse(Console.ReadLine(), out id); } while (!checkInput || id > ItemOfMenu._currentMaxId || id < 0); if (id == 0) { return(false); } do { Console.Write($"Please enter number of item you want to order: "); checkInput = ConvertServices.ToIntByTryParse(Console.ReadLine(), out qty); } while (!checkInput || qty < 0); if (qty == 0) { return(false); } do { Console.Write($"Please enter table you want to add: "); checkInput = ConvertServices.ToIntByTryParse(Console.ReadLine(), out tableNumber); } while (!checkInput || tableNumber < 0 || tableNumber > _shopOrder.ListTables.Count); if (tableNumber == 0) { return(false); } return(true); }