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 IRetrievedContent GetTypedContent(CaaS.Content content) { return(content.ContentTypeAlias switch { Cafe.ContentTypeAlias => Cafe.MapToType(content), CafeCollection.ContentTypeAlias => CafeCollection.MapToType(content), ContentPage.ContentTypeAlias => ContentPage.MapToType(content), Home.ContentTypeAlias => Home.MapToType(content), Product.ContentTypeAlias => Product.MapToType(content), ProductCollection.ContentTypeAlias => ProductCollection.MapToType(content), _ => throw new TypeLoadException($"Unknown type {content.ContentTypeAlias} encountered.") });