private void DeleteMeal() { Console.Clear(); Console.WriteLine("Please enter the meal number of the meal you'd like deleted."); List <Challenge1Items> mealList = _repo.GetItems(); int count = 0; foreach (Challenge1Items meal in mealList) { count++; Console.WriteLine($"{count}. {meal.MealNumber}"); } int targetMealID = int.Parse(Console.ReadLine()); int targetIndex = targetMealID - 1; if (targetIndex >= 0 && targetIndex < mealList.Count) { Challenge1Items desiredMeal = mealList[targetIndex]; if (_repo.DeleteMeal(desiredMeal.MealNumber)) { Console.WriteLine($"{desiredMeal.MealNumber} successfully removed."); } else { Console.WriteLine("Sorry, this is unavailable"); } } else { Console.WriteLine("No Content has that ID"); } }
private void ShowMeals(Challenge1Items meal) { Console.WriteLine($"Meal Number: {meal.MealNumber}\n" + $"Meal Name: {meal.MealName}\n" + $"Description: {meal.Description}\n" + $"Ingredient List: {meal.IngredientList}\n" + $"Price: {meal.MealPrice}\n"); }
//Create public bool AddMeal(Challenge1Items meal) { int startingCount = _menuItems.Count; _menuItems.Add(meal); bool wasAdded = _menuItems.Count > startingCount; return(wasAdded); }
private void AddMeal() { Console.Clear(); Challenge1Items meal = new Challenge1Items(); Console.WriteLine("Please enter a meal Number"); meal.MealNumber = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please enter the name of the Meal."); meal.MealName = Console.ReadLine(); Console.WriteLine("Enter Meal Description"); meal.Description = Console.ReadLine(); Console.WriteLine("Enter Ingredient Lists"); meal.IngredientList = Console.ReadLine(); Console.WriteLine("Enter Meal Price"); meal.MealPrice = Decimal.Parse(Console.ReadLine()); }
public bool DeleteMeal(int mealNumber) { Challenge1Items mealtoDelete = GetMealByNumber(mealNumber); return(_menuItems.Remove(mealtoDelete)); }