private List<leftMenuItem> getStaticLeftMenu(List<tbl_category> list, int selectedPageId) { List<leftMenuItem> helperList = new List<leftMenuItem>(); pageShared ps = new pageShared(db); foreach (var item in list.Where(a => a.statu).OrderBy(a => a.sequence)) { leftMenuItem helper = new leftMenuItem(); helper.name = item.name; var pageItem = item.tbl_page.Where(a => a != null && a.statu).FirstOrDefault(); if (pageItem != null) { helper.url = mainPath + langCode + "/" + ps.getPageUrl(pageItem) + ".html"; if (pageItem.pageId == selectedPageId) { helper.className = "active"; } } else { helper.url = "#"; } helperList.Add(helper); } return helperList; }
public List<leftMenuItem> generateLeftMenu(tbl_page mainAccountPage, string currentPageUrl) { List<leftMenuItem> menuList = new List<leftMenuItem>(); if (mainAccountPage != null && mainAccountPage.tbl_category != null) { var parentCategory = mainAccountPage.tbl_category; var subCategoryList = db.tbl_category.Include("tbl_page").Where(a => a.parentId == parentCategory.categoryId && a.tbl_page.Count > 0).ToList(); foreach (var item in subCategoryList) { leftMenuItem menuItem = new leftMenuItem(); menuItem.url = langCode + "/" + mainAccountPage.url + "/" + item.tbl_page.FirstOrDefault().url + ".html"; menuItem.name = item.name; if (item.tbl_page.FirstOrDefault().url == currentPageUrl) { menuItem.className = "active"; } menuList.Add(menuItem); } } return menuList; }