Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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"));
        }