public ActionResult Index(int editing) { ViewBag.editing = editing; List <int> dsIscheck = new List <int>(); webpages_RolesModel model = new webpages_RolesModel(); List <webpages_UsersInRoles> lstUserInRoles = authorizeService.userInRolesResponsitory.GetAll().Where(i => i.UserId == editing).ToList(); foreach (var j in lstUserInRoles) { dsIscheck.Add(j.RoleId); } ViewBag.IsCheck = dsIscheck; List <webpages_RolesModel> list = authorizeService.GetAll().AsEnumerable().Select(item => new webpages_RolesModel { RoleId = item.RoleId, RoleName = item.RoleName, Description = item.Description, }).ToList(); return(View(list)); }
public List <TreeViewModel> GetTree(decimal roleId) { var mods = RoleService.GetById(roleId); List <TreeViewModel> treeList = new List <TreeViewModel>(); List <AuthorizeDto> listAnthorize = AuthorizeService.GetAll(); foreach (var item in listAnthorize) { TreeViewModel treeuser = new TreeViewModel(); treeuser.id = item.Id.ToString(); treeuser.showcheck = true; treeuser.text = item.Description; treeuser.img = item.Icon; treeuser.parentId = item.ParentId.ToString(); bool hasChildren = listAnthorize.Count(t => t.ParentId == item.Id) == 0 ? false : true; treeuser.isexpand = true; treeuser.checkstate = mods.AuthorizeIds.Contains(item.Id)?1:0; treeuser.complete = true; treeuser.hasChildren = hasChildren; treeList.Add(treeuser); } return(treeList); }