public ActionResult AuthorizationItemEdit(int authorizationId, AuthorizationModel authorizationModel) { try { var authorizationItems = RoleModuleService.GetAll(authorizationId); foreach (var authorizationItem in authorizationItems) { RoleModuleService.DeleteReal(authorizationItem.Id); } var newItems = authorizationModel.RoleModules?.ToList(); if (newItems != null) { foreach (var item in newItems) { var a = new RoleModule { RoleId = authorizationId, ModuleId = item }; RoleModuleService.Add(a); } } } catch (Exception e) { Logger.Error("Hata oluştu - " + new StackTrace().GetFrame(0).GetMethod().Name, e); } return(RedirectToAction("AuthorizationList")); }
/// <summary> /// 获取权限树 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult RoleMenuTree(string id) { AjaxMsgResult msg = new AjaxMsgResult(); ModuleMenuService mmService = new ModuleMenuService(); var mlist = mmService.Get(a => a.Isvalid == 1); RoleModuleService rmmService = new RoleModuleService(); var rmlist = rmmService.Get(a => a.RoleCode == id); List <zTreeData> list = new List <zTreeData>(); foreach (var item in mlist) { zTreeData zd = new zTreeData() { id = item.Controlleraction, name = item.Modulename, open = true, pId = item.ParentControlleraction }; if (!string.IsNullOrEmpty(id)) { foreach (var ritem in rmlist) { if (ritem.ModuleControlleraction == item.Controlleraction) { zd.@checked = true; break; } } } list.Add(zd); } msg.Success = true; msg.Source = list; return(Json(msg)); }
public JsonResult SaveRoleMenu(string id) { string nodes = Request.Form["nodes"]; if (!string.IsNullOrEmpty(nodes)) { nodes = nodes.Trim(','); } RoleModuleService rmmService = new RoleModuleService(); int i = rmmService.UpdateRoleModule(id, nodes); AjaxMsgResult msg = new AjaxMsgResult(); msg.Msg = "保存成功"; return(Json(msg)); }
public ActionResult AuthorizationItemEdit(int authorizationId) { try { var model = new AuthorizationModel { RoleModules = RoleModuleService.GetAll(authorizationId).Select(r => r.ModuleId.Value).ToList(), Role = RoleService.Get(authorizationId), Modules = ModuleService.GetAll() }; return(View(model)); } catch (Exception e) { Logger.Error("Hata oluştu - " + new StackTrace().GetFrame(0).GetMethod().Name, e); return(View(new AuthorizationModel())); } }