Beispiel #1
0
        public IActionResult Edit(NewFoodModel model)
        {
            if (ModelState.IsValid)
            {
                var food = _mapper.NewFoodModelToFood(model, false, _categoryService);
                _foodService.EditFood(food);
                return(RedirectToAction("Index", new { id = model.Id }));
            }

            ViewBag.ActionText     = "change";
            ViewBag.Action         = "Edit";
            ViewBag.CancelAction   = "Index";
            ViewBag.SubmitText     = "Save Changes";
            ViewBag.ControllerName = "Food";
            ViewBag.RouteId        = model.Id;
            GetCategoriesForDropDownList();

            return(View("CreateEdit", model));
        }