예제 #1
0
        public async Task <IActionResult> Edit(IngredientViewModel ingredientVM)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var name = await _ingredientServices.EditIngredienAsync(ingredientVM.MapToDto());

                    _toast.AddErrorToastMessage($"Ingredient {name} was updated!");
                }
                catch (Exception ex)
                {
                    _toast.AddErrorToastMessage(ex.Message);
                    ViewBag.ErrorTitle = "";
                    return(View("Error"));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }