예제 #1
0
        public async Task <IActionResult> EditIngredient(IngredientViewModel model)
        {
            if (ModelState.IsValid)
            {
                var recipeIngredient = await _converterHelper.ToIngredientAsync(model, false);

                _context.RecipeIngredients.Update(recipeIngredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction($"Details/{model.Id}"));
            }


            model.Ingredients = _combosHelper.GetComboIngredients();
            return(View(model));
        }
예제 #2
0
 public IngredientViewModel ToIngredientViewModel(RecipeIngredient ingredient)
 {
     return(new IngredientViewModel
     {
         Id = ingredient.Id,
         Amount = ingredient.Amount,
         Ingredient = ingredient.Ingredient,
         Recipe = ingredient.Recipe,
         Ingredients = _combosHelper.GetComboIngredients(),
         IngredientId = ingredient.Ingredient.Id,
         RecipeId = ingredient.Recipe.Id,
     });
 }