private async Task <IEnumerable <NavigationBarContentTab> > GetContentTabs(NavigationBarElementSettings settings, long pageId) { // Get details of pages that are referenced by navigation tabs IEnumerable <long> pageIds = Enumerable.Concat(settings.Tabs.Select(t => t.PageId), settings.Tabs.SelectMany(t => t.Tabs).Select(t => t.PageId)).Distinct(); IEnumerable <Page> pages = await _pageService.ListPagesAsync(settings.TenantId, pageIds); IDictionary <long, Page> pagesById = pages.ToDictionary(p => p.PageId, p => p); // Get the current page hierarchy IEnumerable <Page> currentPageHierarchy = await _pageService.ListPagesInHierarchyAsync(settings.TenantId, pageId); // Get content tabs return(GetContentTabs(pagesById, currentPageHierarchy, settings.Tabs)); }
public async Task <IElementView <NavigationBarElementSettings, NavigationBarElementContent> > ReadElementViewAsync(long tenantId, long elementId, IPageContext context) { NavigationBarElementSettings settings = await _elementRepository.ReadElementSettingsAsync(tenantId, elementId); if (settings == null) { return(null); } NavigationBarElementContent content = new NavigationBarElementContent { Tabs = await GetContentTabs(settings, context.PageId) }; return(new ElementView <NavigationBarElementSettings, NavigationBarElementContent> { Settings = settings, Content = content }); }