public async Task <ActionResult> Create([FromBody] SysMenuView model) { var resdata = await AutoException.Excute <long>(async (result) => { model.CreateBy = "admin"; model.CreateDt = DateTime.Now; model.ParentID = model.ParentID == null ? 0 : model.ParentID; result.Data = await new SysMenuDAL().InsertAsync(model); if (result.Data == 0) { throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); } else { if (!string.IsNullOrEmpty(model.menubuttons)) { var idstr = Newtonsoft.Json.JsonConvert.DeserializeObject <List <dynamic> >(model.menubuttons); List <SysMenuButton> rolelist = (from p in idstr select new SysMenuButton { MenuID = result.Data, ButtonCode = p.id, ButtonName = p.title, Status = 1, CreateDt = DateTime.Now, CreateBy = model.UpdateBy }).ToList(); await SysMenuButtonDAL.BatchInsertAsync(rolelist); } } }, false); return(Json(resdata)); }
public async Task <ActionResult> UpdateModule(string id) { //获取菜单已经绑定的按钮 var menubuttons = await SysMenuButtonDAL.QueryAsync(u => u.MenuID == Convert.ToInt32(id), null, null); //回去权限按钮字典 (List <SysDictionary> list, long count)buttons = await SysDictionaryDAL.QueryAsync(w => w.Status == 1 && w.Parent.DictNo == AuthorizeName.PermissionButton); ViewBag.ButtonList = buttons.list.Select(s => new SelectListItem { Text = s.DictName, Value = s.DictNo.ToString(), Selected = menubuttons.list.Exists(e => e.ButtonCode == s.DictNo) }).ToList(); (List <SysMenu> list, long count)menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); ViewBag.SysMenuList = menus.list.Select(s => new SelectListItem { Text = s.MenuName, Value = s.Id.ToString() }).ToList(); SysMenuView model = new SysMenuView() { }; if (!string.IsNullOrEmpty(id) && id != "0") { int _id = Convert.ToInt32(id); var tempModel = await new SysMenuDAL().GetByOneAsync(w => w.Id == _id); model = _mapper.Map <SysMenuView>(tempModel); } return(View(model)); }
public static void load(IHtmlHelper htmlHelper, ClaimsPrincipal User) { var _user = Newtonsoft.Json.JsonConvert.DeserializeObject <SysUserView>(User.Identities.First(u => u.IsAuthenticated).FindFirst(ClaimTypes.UserData).Value); if (_user.UserType == UserType.SuperUser) { htmlHelper.ViewContext.FormContext.FormData["IsAdmin"] = true; } else { var _role = _user.userrole.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(s => Convert.ToInt64(s)).ToList(); if (htmlHelper.ViewContext.RouteData.Values.ContainsKey("controller") && htmlHelper.ViewContext.RouteData.Values["controller"] != null && htmlHelper.ViewContext.RouteData.Values["controller"].ToString() == "CompanyObject") { htmlHelper.ViewContext.FormContext.FormData["button_Import"] = false; } //判断是否存在控制器和方法 string controller = ""; string action = ""; string area = ""; if (IsRouteDataKeys(htmlHelper.ViewContext.RouteData, ref area, ref controller, ref action)) { //q =>this.UserID, "/" + controller + "/", RoleIDs); var rolebtn = new SysRoleButtonDAL().Query((s) => _role.Contains(s.RoleId)).list.Select(s => s.ButtonId).ToList(); var showbtns = new SysMenuButtonDAL().Query(s => s.Menu.MenuUrl.IndexOf(area + "/" + controller + "/" + action) != -1 && rolebtn.Contains(s.Id)); foreach (SysMenuButton item in showbtns.list) { if (item.Category == (int)SysModuleButtonCategory.ToolbarButton) { SetPurviewViewData(htmlHelper, item.ButtonCode, "button_"); } else if (item.Category == (int)SysModuleButtonCategory.ListButton) { SetPurviewViewData(htmlHelper, item.ButtonCode, "list_"); } else if (item.Category == (int)SysModuleButtonCategory.GeneralButton) { SetPurviewViewData(htmlHelper, item.ButtonCode, "button_"); SetPurviewViewData(htmlHelper, item.ButtonCode, "list_"); } } } } }
public void LoadToolBarActionButtonRight() { if (this.UserType == UserType.SuperUser) { this.ViewData["IsAdmin"] = true; } else { if (this.RouteData.Values.ContainsKey("controller") && this.RouteData.Values["controller"] != null && this.RouteData.Values["controller"].ToString() == "CompanyObject") { this.ViewData["button_Import"] = false; } //判断是否存在控制器和方法 string controller = ""; string action = ""; string area = ""; if (IsRouteDataKeys(this.RouteData, ref area, ref controller, ref action)) { //q =>this.UserID, "/" + controller + "/", RoleIDs); var rolebtn = base_SysRoleButtonDAL.Query((s) => this.Role.Contains(s.RoleId)).list.Select(s => s.ButtonId).ToList(); var showbtns = new SysMenuButtonDAL().Query(s => s.Menu.MenuUrl.IndexOf(area + "/" + controller + "/" + action) != -1 && rolebtn.Contains(s.Id)); foreach (SysMenuButton item in showbtns.list) { if (item.Category == (int)SysModuleButtonCategory.ToolbarButton) { SetPurviewViewData(item.ButtonCode, "button_"); } else if (item.Category == (int)SysModuleButtonCategory.ListButton) { SetPurviewViewData(item.ButtonCode, "list_"); } else if (item.Category == (int)SysModuleButtonCategory.GeneralButton) { SetPurviewViewData(item.ButtonCode, "button_"); SetPurviewViewData(item.ButtonCode, "list_"); } } } } }