Esempio n. 1
0
        public ActionResult EditItem(MenuItemRecordModel itemModel, bool continueEditing, FormCollection form)
        {
            if (!Services.Permissions.Authorize(StandardPermissionProvider.ManageMenus))
            {
                return(AccessDeniedView());
            }

            var item = _menuStorage.GetMenuItemById(itemModel.Id);

            if (item == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                MiniMapper.Map(itemModel, item);
                item.ParentItemId    = itemModel.ParentItemId ?? 0;
                item.PermissionNames = string.Join(",", itemModel.PermissionNames ?? new string[0]).NullEmpty();

                _menuStorage.UpdateMenuItem(item);

                UpdateLocales(item, itemModel);

                Services.EventPublisher.Publish(new ModelBoundEvent(itemModel, item, form));
                NotifySuccess(T("Admin.Common.DataSuccessfullySaved"));

                if (continueEditing)
                {
                    return(RedirectToAction("EditItem", new { id = item.Id }));
                }

                return(RedirectToAction("Edit", new { id = item.MenuId }));
            }

            PrepareModel(itemModel, item);

            return(View(itemModel));
        }