Пример #1
0
        //Update existing content
        private void UpdateExistingMenuItems()
        {
            // Display all content
            DisplayAllMenuItems();
            // Ask for the title of the content to update
            Console.WriteLine("Enter the menu item you want to update:");

            // Get that title
            string oldMenuItems = Console.ReadLine();
            // Build a new menu item
            MenuItems newMenuItems = new MenuItems();

            //Meal Name
            Console.WriteLine("Enter the name of the meal:");
            newMenuItems.MealName = Console.ReadLine();
            //Meal Number
            Console.WriteLine("Enter the meal number ex: a #5 please");
            string mealNumberAsString = Console.ReadLine();

            newMenuItems.MealNumber = int.Parse(mealNumberAsString);
            //Item Description
            Console.WriteLine("Enter the meal description");
            newMenuItems.ItemDescription = Console.ReadLine();
            //Price
            Console.WriteLine("Enter the price of the meal");
            string priceAsString = Console.ReadLine();

            newMenuItems.Price = decimal.Parse(priceAsString);
            //Ingredients
            Console.WriteLine("Enter the ingredients used");
            newMenuItems.Ingredients = Console.ReadLine();

            //Verify the update worked
            bool wasUpdated = _menuItemsRepo.UpdateExistingMenuItems(oldMenuItems, newMenuItems);

            if (wasUpdated)
            {
                Console.WriteLine("Menu item was updated!");
            }
            else
            {
                Console.WriteLine("Menu item could not be updated!");
            }
        }