public List <WecharMenu> GetChild(List <YaeherConditionalMenu> MenuList, int Id) { List <WecharMenu> child = new List <WecharMenu>(); var ChildList = MenuList.Where(a => a.ParentID == Id).ToList(); if (ChildList.Count > 0) { foreach (var item in ChildList) { WecharMenu wecharMenu = new WecharMenu(); wecharMenu.Id = item.Id; wecharMenu.RoleCode = item.RoleCode; wecharMenu.RoleName = item.RoleName; wecharMenu.TagId = item.TagId; wecharMenu.ConditionalName = item.ConditionalName; wecharMenu.ConditionalType = item.ConditionalType; wecharMenu.ConditionalTypeName = item.ConditionalTypeName; wecharMenu.ConditionalUrl = item.ConditionalUrl; wecharMenu.AppID = item.AppID; wecharMenu.Pagepath = item.Pagepath; wecharMenu.ParentID = item.ParentID; wecharMenu.MenuID = item.MenuID; wecharMenu.CreatedOn = item.CreatedOn; if (MenuList.Where(a => a.ParentID == item.Id).ToList().Count > 0) { wecharMenu.children = GetChild(MenuList, item.Id); } child.Add(wecharMenu); } } return(child); }
public async Task <IList <WecharMenu> > YaeherModuleList(YaeherConditionalMenuIn YaeherConditionalMenuInfo) { var query = await _menurepository.GetAll().Where(YaeherConditionalMenuInfo.Expression).ToListAsync(); List <WecharMenu> wecharMenus = new List <WecharMenu>(); List <YaeherConditionalMenu> yaeherConditionalMenus = query.Where(a => a.ParentID == 0).ToList(); foreach (var item in yaeherConditionalMenus) { WecharMenu wecharMenu = new WecharMenu(); wecharMenu.Id = item.Id; wecharMenu.RoleCode = item.RoleCode; wecharMenu.RoleName = item.RoleName; wecharMenu.TagId = item.TagId; wecharMenu.ConditionalName = item.ConditionalName; wecharMenu.ConditionalType = item.ConditionalType; wecharMenu.ConditionalTypeName = item.ConditionalTypeName; wecharMenu.ConditionalUrl = item.ConditionalUrl; wecharMenu.AppID = item.AppID; wecharMenu.Pagepath = item.Pagepath; wecharMenu.ParentID = item.ParentID; wecharMenu.MenuID = item.MenuID; wecharMenu.CreatedOn = item.CreatedOn; wecharMenu.children = GetChild(query.ToList(), item.Id); wecharMenus.Add(wecharMenu); } return(wecharMenus); }