public IActionResult Create() { var mealFactory = new MyKitchen.Data.MealFactory(context); Meal meal = mealFactory.NewMeal(); var viewModel = new MealBuilderCreateViewModel() { FoodItems = foodItemRepository.GetFoodItems().ToList() }; return(View(viewModel)); }
public async Task <IActionResult> SaveNewMeal(MealBuilderCreateViewModel model) { var meal = model.Meal; meal.AppUser = CurrentUser.User; if (ModelState.IsValid) { await mealRepository.Add(meal); } // return RedirectToAction("Details"); return(Redirect($"/MealBuilder/MealDetails/{meal.MealID}?editMode=false")); }