public List<Common.AccordionItem> GetCurrentUserMenu(System.Web.Mvc.Controller controller) { List<AccordionItem> menulist = new List<AccordionItem>(); IList<SmartBox.Console.Common.Privilege> list = GetList(controller); if (list != null) { var topmenu = list.Where(x => x.ParentID == "0"); if (topmenu != null) { foreach (SmartBox.Console.Common.Privilege p in topmenu) { AccordionItem item = new AccordionItem(); item.Text = p.PrivilegeName; item.Code = p.PrivilegeCode; item.IsExpand = false; item.Url = p.Uri; item.ID = p.ID; item.IcoSrc = ""; SmartBox.Console.Common.Privilege privilege = p; var child = list.Where(x => x.ParentID == privilege.ID.ToString()); if (child != null) { foreach (SmartBox.Console.Common.Privilege pc in child) { AccordionItem citem = new AccordionItem(); citem.Text = pc.PrivilegeName; citem.Code = pc.PrivilegeCode; citem.Url = pc.Uri; citem.IcoSrc = ""; citem.ID = pc.ID; citem.Type = pc.PrivilegeType.ToString(); //检查citem的节点,如有则添加 SmartBox.Console.Common.Privilege lefprivilege = pc; var childleaf = list.Where(x => x.ParentID == pc.ID.ToString()); foreach (SmartBox.Console.Common.Privilege pcleaf in childleaf) { AccordionItem litem = new AccordionItem(); litem.Text = pcleaf.PrivilegeName; litem.Code = pcleaf.PrivilegeCode; litem.Url = pcleaf.Uri; litem.IcoSrc = ""; litem.ID = pcleaf.ID; citem.Children.Add(litem); } item.Children.Add(citem); } } menulist.Add(item); } } } return menulist; }
public List<Common.AccordionItem> GetCurrentUserMenu(System.Web.Mvc.Controller controller) { List<AccordionItem> menulist = new List<AccordionItem>(); IList<SmartBox.Console.Common.Privilege> list = GetList(controller); if (list != null) { var topmenu = list.Where(x => x.ParentID == "0"); if (topmenu != null) { foreach (SmartBox.Console.Common.Privilege p in topmenu) { AccordionItem item = new AccordionItem(); item.Text = p.PrivilegeName; item.Code = p.PrivilegeCode; item.IsExpand = false; item.Url = p.Uri; item.IcoSrc = ""; SmartBox.Console.Common.Privilege privilege = p; var child = list.Where(x => x.ParentID == privilege.PrivilegeCode); if (child != null) { foreach (SmartBox.Console.Common.Privilege pc in child) { AccordionItem citem = new AccordionItem(); citem.Text = pc.PrivilegeName; citem.Code = pc.PrivilegeCode; citem.Url = pc.Uri; citem.IcoSrc = ""; item.Children.Add(citem); } } menulist.Add(item); } } } return menulist; }