public async Task <IActionResult> Menu() { var menuSelectData = new Dictionary <int, string>(); var menuList = await _menuInfoRepository.Query(x => x.MenuLevel == 1 || x.MenuLevel == 2, x => x.OrderFlag); foreach (var item in menuList) { if (item.ParentId == 0) { menuSelectData.Add(item.Id, item.MenuName); } else { var parentMenu = await _menuInfoRepository.QueryById(item.ParentId); menuSelectData.Add(item.Id, parentMenu.MenuName + ">>" + item.MenuName); } } return(View(menuSelectData)); }
public async Task <IViewComponentResult> InvokeAsync(string mname) { List <MenuModel> menuModels = new List <MenuModel>(); var menuList = await _menuInfoRepository.Query(x => x.IsDelete != 1, x => x.OrderFlag); foreach (var item in menuList) { var child = menuList.Where(x => x.ParentId == item.Id).ToArray(); var active = mname == item.MenuName ? true : false; var temp = new MenuModel() { HasChild = child.Length > 0 ? true : false, IsActive = active, IsCloseItem = active == true ? false : true, MenuIcon = item.MenuIcon, MenuName = item.MenuName, MenuLevel = item.MenuLevel, Id = item.Id, ParentId = item.ParentId, MenuUrl = item.MenuUrl }; menuModels.Add(temp); } return(View(menuModels)); }