public ActionResult Index() { IOrgService orgService = this.CreateService <IOrgService>(); List <SysOrgType> orgTypes = orgService.GetOrgTypes(); List <Select2Group> orgGroups = new List <Select2Group>(); List <SysOrg> orgs = orgService.GetList(); foreach (var item in orgs.GroupBy(a => a.OrgType).OrderBy(a => a.Key)) { int? orgType = item.Key; string orgTypeName = orgTypes.Where(a => a.Id == orgType).Select(a => a.Name).FirstOrDefault(); Select2Group group = new Select2Group(orgTypeName); group.children.AddRange(item.Select(a => new Select2Item(a.Id, a.Name))); orgGroups.Add(group); } this.ViewBag.Orgs = orgGroups; List <SysRole> roles = this.CreateService <IRoleService>().GetList(); this.ViewBag.Roles = roles.Select(a => new Select2Item() { id = a.Id, text = a.Name }); List <Ace.Entity.Wiki.SimpleShop2> shops = this.CreateService <Ace.Application.Wiki.IShopService>().GetCacheList2(); this.ViewBag.Shops = shops; return(View()); }