private void RemoveItemFromList()
        {
            Console.Clear();
            Console.WriteLine("Which item would you like to remove");
            List <MenuItem> itemsInList = _repository.GetItems();
            int             count       = 0;

            foreach (MenuItem item in itemsInList)
            {
                count++;
                Console.WriteLine($"{count}. {item.MealName}");
            }
            int targetItemName = int.Parse(Console.ReadLine());
            int targetIndex    = targetItemName - 1;

            if (targetIndex >= 0 && targetIndex < itemsInList.Count())
            {
                MenuItem desiredItem = itemsInList[targetIndex];
                if (_repository.DeleteItem(desiredItem.MealName))
                {
                    Console.WriteLine($"{desiredItem.MealName} has been removed.");
                }
                else
                {
                    Console.WriteLine("I'm sorry, I can't do that.");
                }
            }
            else
            {
                Console.WriteLine("No item has that name");
            }
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private void DeleteMenuItem()
        {
            Console.Clear();

            Console.WriteLine("Select a Menu Item to be removed");

            List <MenuItem> itemList = _repo.GetItems();

            int count = 0;

            foreach (MenuItem item in itemList)
            {
                count++;
                Console.WriteLine($"{count}.{item.MealName}");
            }

            int targetItemId = int.Parse(Console.ReadLine());
            int targetIndex  = targetItemId - 1;

            if (targetIndex >= 0 && targetIndex < itemList.Count)
            {
                MenuItem chosenItem = itemList[targetIndex];

                if (_repo.DeleteItemFromDirectory(chosenItem.MealName))
                {
                    Console.WriteLine($"{chosenItem.MealName} removed");
                }
                else
                {
                    Console.WriteLine("Please try again");
                }
            }
            else
            {
                Console.WriteLine("Not a valid Meal Name");
            }
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public void AddTest()
        {
            MenuItem item1 = new MenuItem(
                1,
                "The Big One",
                "A half pound of beef between on a warm brioche bun, topped with a slice of cheddar cheese and crisp onion and lettuce.",
                7.99m,
                "cheese, beef, lettuce, onion, brioche bun");

            bool itemadded = _repo.AddMenuItemtoDirectory(item1);

            Assert.IsTrue(itemadded);
            Console.WriteLine(item1.Ingredients);
            Console.WriteLine(_repo.GetItems().Count);
        }