public static void FilterByCategory(ref RestarurantManager restarurantManager) { Console.WriteLine("Choose the category:"); string[] categoryNames = Enum.GetNames(typeof(Category)); for (int i = 0; i < categoryNames.Length; i++) { Console.WriteLine(" " + i + "-" + categoryNames[i]); } string selectedEnumStr = Console.ReadLine(); int selectedEnumInt; while (!int.TryParse(selectedEnumStr, out selectedEnumInt) || selectedEnumInt < 0 || selectedEnumInt >= categoryNames.Length) { Console.WriteLine("Error! Choose the right option:"); selectedEnumStr = Console.ReadLine(); } Category selectedCategory = (Category)selectedEnumInt; try { restarurantManager.ShowAllItems(restarurantManager.MenuItemsSortByCategory(selectedCategory)); } catch (MenuItemDoesNotExist ex) { Console.WriteLine("Error:" + ex.Message); } }
public static void FilterByPrices(ref RestarurantManager restarurantManager) { Console.WriteLine("Price:"); string priceStr = Console.ReadLine(); double price; while (!double.TryParse(priceStr, out price) || price < 0) { Console.WriteLine("Error! Write the MenuItem price properly:"); priceStr = Console.ReadLine(); } Console.WriteLine("Price 2:"); string priceStr1 = Console.ReadLine(); double price1; while (!double.TryParse(priceStr1, out price1) || price1 < 0) { Console.WriteLine("Error! Write the MenuItem price properly:"); priceStr1 = Console.ReadLine(); } try { restarurantManager.ShowAllItems(restarurantManager.MenuItemsSortByPrice(price, price1)); } catch (MenuItemDoesNotExist ex) { Console.WriteLine("Error:" + ex.Message); } }
public static void SearchByName(ref RestarurantManager restarurantManager) { Console.WriteLine("Menu item name:"); string menuItemName = Console.ReadLine(); while (string.IsNullOrWhiteSpace(menuItemName)) { Console.WriteLine("Error! Write the MenuItem name properly:"); menuItemName = Console.ReadLine(); } try { restarurantManager.ShowAllItems(restarurantManager.MenuItemsSearch(menuItemName)); } catch (MenuItemDoesNotExist ex) { Console.WriteLine("Error:" + ex.Message); } }
public static void ShowAllItems(ref RestarurantManager restarurantManager) { restarurantManager.ShowAllItems(); }