コード例 #1
0
        public void SeedRepository()
        {
            MenuItem item = new MenuItem(1, "Burger Meal", "Burger Fries and a Drink", new List <string> {
                "burger", "fries", "drink"
            }, 3.99);
            MenuItem item2 = new MenuItem(2, "Potato Meal", "Baked Potato and a Drink", new List <string> {
                "Packed Spud", "drink"
            }, 2.99);

            _repo.AddMenuItemToList(item);
            _repo.AddMenuItemToList(item2);
        }
コード例 #2
0
        }     //Menu method

        //Add menu item
        private void AddMenuItem()
        {
            Console.Clear();
            MenuItem newItem = new MenuItem();

            //Meal Number
            Console.WriteLine("Enter the meal number: ");
            string mealNumberAsString = Console.ReadLine();

            newItem.Meal_Number = int.Parse(mealNumberAsString);

            //Meal Name
            Console.WriteLine("Enter the meal name ");
            newItem.Meal_Name = Console.ReadLine();

            //Description
            Console.WriteLine("Enter the meal description: ");
            newItem.Description = Console.ReadLine();

            //Ingredients List

            string ingredient = "";

            while (ingredient != "end")
            {
                Console.WriteLine("Enter an ingrdient ('end' to complete list): ");
                ingredient = Console.ReadLine();
                if (ingredient != "end")
                {
                    newItem.IngredientsList.Add(ingredient);
                }
            }

            //Price
            Console.WriteLine("Enter the meal price: ");
            string priceAsString = Console.ReadLine();

            newItem.Price = double.Parse(priceAsString);

            _menuRepo.AddMenuItemToList(newItem);
        }