// GET: Meals/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var meal = await _context.Meals.SingleOrDefaultAsync(m => m.ID == id); if (meal == null) { return(NotFound()); } else { ViewMealViewModel viewMealViewModel = new ViewMealViewModel( meal.ID, meal.Name, meal.Description, meal.Location, _context.WeatherTypes.ToList(), meal.WeatherTypeID, _context.CookingMethods.ToList(), meal.CookingMethodID, _context.CookingMethods.ToList(), meal.AltCookingMethodID, _context.CookingTimes.ToList(), meal.CookingTimeID, _context.PrepTimes.ToList(), meal.PrepTimeID); return(View(viewMealViewModel)); } }
public IActionResult ViewAMeal(ViewMealViewModel viewMealViewModel) { ViewMealViewModel vMVM = new ViewMealViewModel(); vMVM.Meal = context.Meals.Include(m => m.Ingredients).Single(mi => mi.ID == viewMealViewModel.ID); //ViewMealViewModel viewMealViewModel = new ViewMealViewModel //{ // Meal = meal, // Ingredients = ingredients //}; return(View(vMVM)); }