public ActionResult GetDataGrid(Pagination p) { var webid = Guid.Empty; var strwebid = HttpContext.Request.Form["webid"]; Guid.TryParse(strwebid, out webid); ModuleDTOList groupdata = new ModuleDTOList(); using (ServiceProxy <IWebService> proxy = new ServiceProxy <IWebService>()) { groupdata = proxy.Channel.GetAllWebModules(webid, true); } groupdata.ForEach(g => g.ChildModule = null); var result = new DataGrid() { total = groupdata.Count, rows = groupdata }; return(Json(result)); }
public List <Permission> GetPermissionByUserID(Guid accountid, Guid webid, bool IsAdmin = false) { List <Permission> plist = new List <Permission>(); ModuleDTOList mdtolist = new ModuleDTOList(); var user = userRepository.Find(Specification <User> .Eval(u => u.Status == Wings.Domain.Model.Status.Active).And(Specification <User> .Eval(u => u.ID.Equals(accountid)))); if (user == null) { return(plist); } ModuleDTOList resultmdtolist = new ModuleDTOList(); if (IsAdmin) { var web = webRepository.Get(Specification <Web> .Eval(w => w.ID.Equals(webid))); if (web != null && web.Modules != null) { web.Modules.ForEach(m => { resultmdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); } } else { //添加用户组模块 user.Groups.ForEach(g => { if (g.Status.Equals(Wings.Domain.Model.Status.Active)) { g.Modules.ForEach( m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); } }); user.Roles.FindAll(t => t.Status == Wings.Domain.Model.Status.Active).ForEach(r => { r.Modules.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); }); user.ModuleAllow.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); //去除重复项 mdtolist.GroupBy(m => m.ID).ToList().ForEach(m => { resultmdtolist.Add(mdtolist.Find(mt => mt.ID == m.Key)); }); //去除禁用的 user.ModuleBan.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { //if (resultmdtolist.Contains(Mapper.Map<Module, ModuleDTO>(m))) //{ resultmdtolist.RemoveAll(mm => mm.ID.Equals(Mapper.Map <Module, ModuleDTO>(m).ID)); //} }); } resultmdtolist.ForEach(r => plist.Add(Mapper.Map <ModuleDTO, Permission>(r))); return(plist); }