Exemple #1
0
        public IActionResult Edit(int id, MenuEditViewModel model)
        {
            if (id != model.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Menu menu = new Menu
                    {
                        ID      = model.ID,
                        Naam    = model.Name,
                        OwnerID = model.OwnerID
                    };
                    _menuManager.EditMenu(menu);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MenuExists(model.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult EditMenu(MenuViewModel menuViewModel)
        {
            try {
                if (ModelState.IsValid)
                {
                    var menu = new MenuModel {
                        Id        = menuViewModel.Id,
                        Code      = menuViewModel.Code,
                        TitleMenu = menuViewModel.TitleMenu
                    };
                    _menuManager.EditMenu(menu);

                    return(RedirectToAction("ManagementMenu"));
                }
            }
            catch (ValidationException ex) {
                ModelState.AddModelError(ex.Property, ex.Message);
            }

            return(View(menuViewModel));
        }