public async Task <IViewComponentResult> InvokeAsync(string name, string viewName = "Default") { var viewModel = await Task.Run(() => _menuFacade.GetByName(SiteId, name, _contextService.GetCurrentLanguageInfo().Id)); var menuItemsToRemove = new List <MenuViewModel.MenuItem>(); foreach (var menuItemViewModel in viewModel.MenuItems) { if (!_userService.IsUserAuthorized(User, menuItemViewModel.ViewRoles)) { menuItemsToRemove.Add(menuItemViewModel); } } if (menuItemsToRemove.Any()) { foreach (var menuItemToRemove in menuItemsToRemove) { viewModel.MenuItems.Remove(menuItemToRemove); } } return(View(viewName, viewModel)); }
public IActionResult Get(string name) { var menu = _menuFacade.GetByName(SiteId, name); return(Ok(menu)); }
public async Task <IActionResult> Get(string name) { var menu = await Task.Run(() => _menuFacade.GetByName(SiteId, name)); return(Ok(menu)); }