Beispiel #1
0
        private void RemoveDish()
        {
            Console.WriteLine("Select menu that you wish to delete a dish from:");
            PrintMenuName();
            int  menuNumber = ReadInt("Your Selection:", 1, restaurant.MenuCount);
            Menu menu       = restaurant.Menus[menuNumber - 1];

            if (menu.DishCount == 0)
            {
                Console.WriteLine("This menu has no dishes to be removed!");
                return;
            }

            Console.WriteLine("Select category that you wish to delete a dish from:");
            PrintStrings(menu.GetNamesOfCategories());
            int categoryInt = ReadInt("Your Selection:",
                                      1, Enum.GetNames(typeof(Menu.Category)).Length);

            Menu.Category  category     = (Menu.Category)categoryInt;
            MenuCategories menuCategory = menu.Categories[categoryInt - 1];

            if (menuCategory.Dishes.Count == 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Removing dish failed because category is empty!");
                Console.ResetColor();
                return;
            }

            PrintStrings(menu.GetNamesOfDishes(category));
            int dishNumber = ReadInt("Select the ID number of dish to be removed:", 1, menu.DishCount);

            menu.RemoveDish(category, dishNumber - 1);
        }
Beispiel #2
0
        public List <string> GetNamesOfDishes(Category category)
        {
            MenuCategories dishCategory = Categories[(int)category];
            List <string>  list         = new List <string>();

            foreach (var dish in dishCategory.Dishes)
            {
                list.Add(dish.Name);
            }
            return(list);
        }