/// <summary> /// Get current page path. /// </summary> /// <returns></returns> public async Task <Dictionary <string, string> > GetNavPath() { // Checking... if (IsValid() == false || Page == null) { return(null); } Page page = Page; SiteClaim cat = Cat; bool addPage = false; PageProvider provider = new PageProvider(this); Dictionary <string, string> path = new Dictionary <string, string>() { }; // Url extension... string urlExtension = (_Controller == "Post" && _Action == "Calendar") ? "/cldr" : null; // Add the current category... if (Post != null && cat != null) { path.Add(cat.StringValue, page.GetCategoryUrl(this, cat, urlExtension)); } // Add cats... if (cat != null && _Controller != null && _Action != null) { // Add the current cat... //path.Add(cat.StringValue, page.GetCategoryUrl(this, cat, urlExtension)); // Add the parent cats... while (cat?.ParentId != null && (cat = Site?.GetCategory(cat.ParentId.Value)) != null) { // Add the parent cat (do not add the page category)... if (cat.Id == page.Category1 || cat.Id == page.Category2 || cat.Id == page.Category3 || cat.Id == page.Category4 || cat.Id == page.Category5 || cat.Id == page.Category6 || cat.Id == page.Category7 || cat.Id == page.Category8 || cat.Id == page.Category9 || cat.Id == page.Category10) { break; } path.Add(cat.StringValue, page.GetCategoryUrl(this, cat, urlExtension)); } // Add the current page... addPage = true; } else if (Post != null) { // Add the current page... addPage = true; } // Add the current page... if (page != null && addPage == true) { path.Add(page.Title, page.GetUrl(this)); } // Add the parent pages... while (page?.ParentId != null && (page = await provider?.Get(page.ParentId.Value)) != null) { // Add the parent page... path.Add(page.Title, page.GetUrl(this)); } //if (Site.HasRegions == true) //{ // path.Add(Region?.StringValue, $"/{Region?.StringValue.ToLower()}"); //} //else //{ // path.Add("Home", "/"); //} // Trace performance... AddPerfLog("AppContext::GetNavPath"); return(path); }
/// <summary> /// The Page api controller constructor. /// </summary> /// <param name="appContext"></param> public PageApiController(Services.WcmsAppContext appContext) : base(appContext) { provider = new PageProvider(AppContext); }