예제 #1
0
        private void RemoveMenuItemFromList()
        {
            Console.WriteLine("Which item would you like to remove?");
            int             count       = 0;
            List <CafeMenu> contentList = _listOfMenuItems.GetMenuItems();

            foreach (CafeMenu content in contentList)
            {
                count++;
                Console.WriteLine($"{count}. {content.TypeOfOrder}");
            }

            int contentNumber      = int.Parse(Console.ReadLine());
            int contentIndexNumber = contentNumber - 1;

            if (contentIndexNumber >= 0 && contentIndexNumber < contentList.Count)
            {
                CafeMenu desiredContent = contentList[contentIndexNumber];
                if (_listOfMenuItems.RemoveMenuItemFromList(desiredContent))
                {
                    Console.WriteLine($"{desiredContent.TypeOfOrder} successfully removed");
                }
                else
                {
                    Console.WriteLine("404 Menu Item Not Found");
                }
            }
            else
            {
                Console.WriteLine("No content has that ID.");
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }