示例#1
0
        public async Task <IActionResult> EditPost(Guid id)
        {
            //MenuItemVm.MenuItem = await _service.GetFullMenuItem(id);
            MenuItemVm.MenuItem.SubCategoryId = new Guid(Request.Form["SubCategoryId"].ToString());

            if (id != MenuItemVm.MenuItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string root  = _hostEnv.WebRootPath;
                    var    files = HttpContext.Request.Form.Files;
                    var    res   = await _service.EditAsync(files, root, MenuItemVm);
                }
                catch (Exception)
                {
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                MenuItemVm.SubCategory = await _service
                                         .GetSubcategory(MenuItemVm.MenuItem.SubCategoryId);

                return(View(MenuItemVm));
            }
        }
        public async Task <ActionResult> Edit(EditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.RoleList = await _roleService.GetAsync();

                return(View(model));
            }

            await _menuItemService.EditAsync(model.MenuItemId, model.LinkText, model.LinkURL, model.LinkIcon);

            await _menuItemService.RolesAsync(model.MenuItemId, model.SelectedRoleList);

            await ResetSessionMenuAsync(model.MenuId);

            return(Content("Refresh"));
        }