Example #1
0
        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));
        }
Example #2
0
        public IActionResult Get(string name)
        {
            var menu = _menuFacade.GetByName(SiteId, name);

            return(Ok(menu));
        }
Example #3
0
        public async Task <IActionResult> Get(string name)
        {
            var menu = await Task.Run(() => _menuFacade.GetByName(SiteId, name));

            return(Ok(menu));
        }