//查询 public IActionResult Index(int Page = 1, int PageSize = 5) { //保存每页记录数 ViewBag.PageSize = PageSize; var menuDtos = _menuAppService.GetAllDtos(); return(View(menuDtos.ToPagedList(Page, PageSize))); }
public IViewComponentResult Invoke() { List <MenuDto> menuDtos = new List <MenuDto>(); string currentUser = HttpContext.Session.GetString("CurrentUser"); if (currentUser == "admin")//如果为超级管理员 { menuDtos = _menuAppService.GetAllDtos(); } else//普通用户 { var currentUserID = HttpContext.Session.GetString("CurrentUserID"); menuDtos = _menuAppService.GetMenusByUser(int.Parse(currentUserID)); } return(View(menuDtos)); }
//调用 public IViewComponentResult Invoke() { List <MenuDto> menuDtos = new List <MenuDto>(); string onlineUser = HttpContext.Session.GetString("CurrentUser"); if (onlineUser == "admin") //如果是admin用户 { menuDtos = _menuAppService.GetAllDtos(); //获取全部功能 } else { string onlineUserID = HttpContext.Session.GetString("CurrentUserID"); menuDtos = _menuAppService.GetMenusByUser(int.Parse(onlineUserID)); } //返回到界面 return(View(menuDtos)); }