private void RemoveFromMenu()
        {
            Console.Clear();
            Console.WriteLine("Which meal item would you like to remove?");
            List <MenuDetails> menuDetails = _menuRepository.GetDetails();
            int count = 0;

            foreach (MenuDetails content in menuDetails)
            {
                count++;
                Console.WriteLine($"{count}. {content.Name}");
            }
            int targetNumber = int.Parse(Console.ReadLine());
            int targetName   = targetNumber - 1;

            if (targetName >= 0 && targetName < menuDetails.Count)
            {
                MenuDetails expectedItem = menuDetails[targetName];
                if (_menuRepository.RemoveExistingItem(expectedItem))
                {
                    Console.WriteLine($"{expectedItem.Name} was removed successfully.");
                }
                else
                {
                    Console.WriteLine("The expected item was unable to be located and removed.");
                }
            }
        }
 private void DisplayMenuItem(MenuDetails content)
 {
     Console.WriteLine($"Item Number: {content.Number}\n" +
                       $"Item Name: {content.Name}\n" +
                       $"Item Description: {content.Description}\n" +
                       $"Item Ingredients: {content.Ingredients}\n" +
                       $"Item Price: {content.Price}\n");
 }
示例#3
0
        public bool AddMenuDetails(MenuDetails content)
        {
            int startingCount = _menuDetails.Count;

            _menuDetails.Add(content);

            bool wasAdded = (_menuDetails.Count > startingCount) ? true : false;

            return(wasAdded);
        }
        private void AddToMenu()
        {
            Console.Clear();
            MenuDetails content = new MenuDetails();

            Console.WriteLine("Add a menu item here.");
            Console.WriteLine("Please enter a menu number:");
            string numberInput  = Console.ReadLine();
            int    numberNumber = int.Parse(numberInput);

            content.Number = numberNumber;
            Console.WriteLine("Please enter a name for the item here:");
            content.Name = Console.ReadLine();
            Console.WriteLine("Please enter a description of the item here:");
            content.Description = Console.ReadLine();
            Console.WriteLine("Please enter a list of ingredients in the item here:");
            content.Ingredients = Console.ReadLine();
            Console.WriteLine("Please enter the price of the item here:");
            string priceInput = Console.ReadLine();
            double pricePrice = double.Parse(priceInput);

            content.Price = pricePrice;
            _menuRepository.AddMenuDetails(content);
        }
示例#5
0
        public bool RemoveExistingItem(MenuDetails existingItem)
        {
            bool removeItem = _menuDetails.Remove(existingItem);

            return(removeItem);
        }