Ejemplo n.º 1
0
        public async Task <List <MenuItem> > GetKendoMenuItemsAsync(string navMenuId)
        {
            var menuItems = new List <MenuItem>();
            var navMenu   = await _navMenuManager.GetFullNavMenuAsync(navMenuId);

            if (navMenu != null)
            {
                await LoadNodesIntoKendoMenuItemsAsync(navMenu.MenuItems, menuItems);
            }
            return(menuItems);
        }
Ejemplo n.º 2
0
        public async Task <IViewComponentResult> InvokeAsync(string navMenuId, string itemId = null)
        {
            if (string.IsNullOrEmpty(navMenuId))
            {
                return(new ViewComponentPlaceholder());
            }

            var navMenu = await _navigationMenuManager.GetFullNavMenuAsync(navMenuId);

            if (navMenu == null)
            {
                return(new ViewComponentPlaceholder());
            }

            var model = new NavigationMenuViewModel();

            model.Id     = navMenu.Id;
            model.SiteId = navMenu.SiteId;
            model.Title  = navMenu.Title;
            foreach (var item in navMenu.MenuItems)
            {
                var node = new TreeViewItemModel();
                LoadItemIntoNode(item, node);
                model.Items.Add(node);
            }
            if (!string.IsNullOrEmpty(itemId))
            {
                ExpandToNode(itemId, model.Items);
            }

            ViewData["FormTitle"] = "Edit Navigation Menu:";
            return(View(model));
        }