示例#1
0
        public async Task <IViewComponentResult> InvokeAsync(string NavigationParentPath, string CurrentPage = null)
        {
            // Use ViewBag to set current Path
            if (!string.IsNullOrWhiteSpace(CurrentPage))
            {
                if (CurrentPage == "/Home")
                {
                    // Special case for Home since the Link is just "/"
                    CurrentPage = "/";
                }
            }
            else
            {
                if (DataRetriever.TryRetrieve(out IPageDataContext <TreeNode> Context))
                {
                    CurrentPage = UrlHelper.Content(DocumentURLProvider.GetUrl(Context.Page));
                }
            }

            NavigationParentPath = !string.IsNullOrWhiteSpace(NavigationParentPath) ? NavigationParentPath : "/MasterPage/Navigation";
            var NavItems = await NavigationRepository.GetNavItemsAsync(NavigationParentPath);

            var model = new NavigationViewModel()
            {
                NavItems        = NavItems.ToList(),
                CurrentPagePath = CurrentPage
            };


            return(View(model));
        }
        public async Task <IViewComponentResult> InvokeAsync(string NavigationParentPath, string CssClass = "MainNav")
        {
            NavigationParentPath = !string.IsNullOrWhiteSpace(NavigationParentPath) ? NavigationParentPath : "/MasterPage/Navigation";
            var NavItems = await NavigationRepository.GetNavItemsAsync(NavigationParentPath);

            var model = new NavigationViewModel()
            {
                NavItems        = NavItems.ToList(),
                NavWrapperClass = CssClass
            };

            return(View(model));
        }