public async Task <IViewComponentResult> InvokeAsync(CaaS.Content cafeRoot = null) { var isCollectionPage = true; if (cafeRoot == null) { var productRootPaged = await _contentCache.GetByType(CafeCollection.ContentTypeAlias, "en-US"); cafeRoot = productRootPaged.Content.Items.FirstOrDefault(); isCollectionPage = false; } if (cafeRoot == null) { throw new Exception("Product Root is null"); } var cafeCollection = CafeCollection.MapToType(cafeRoot); var children = await _contentCache.GetChildren(cafeRoot.Id, "en-US"); cafeCollection.IsCollectionPage = isCollectionPage; cafeCollection.Cafes = children.Content.Items.Select(c => Cafe.MapToType(c)); return(View(cafeCollection)); }
public async Task <IViewComponentResult> InvokeAsync() { var rootContent = await _contentCache.GetContentByUrl("/", "en-US") as CaaS.Content; var homeNode = Home.MapToType(rootContent); var children = await _contentCache.GetChildren(rootContent.Id); var navItems = children.Content.Items.Where(x => x.IsVisible()) .Select(item => new NavigationItem { Title = item.Name, Url = item.Url.ToSafeUrl(), IsCurrent = item.Url == Request.Path.ToString() }).ToList(); navItems.Insert(0, new NavigationItem { Title = homeNode.Title, Url = homeNode.Url, IsCurrent = homeNode.Url == Request.Path.ToString() }); var navViewModel = new NavigationViewModel() { IsHomePage = rootContent.Url == Request.Path.ToString(), NavigationItems = navItems, Root = homeNode }; return(View(navViewModel)); }