IEnumerable <IVariationViewModel <VariationContent> > CreateRelatedVariationViewModelCollection(CatalogContentBase catalogContent, string associationType) { IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink); IEnumerable <IVariationViewModel <VariationContent> > productViewModels = Enumerable.Where(associations, p => p.Group.Name.Equals(associationType) && IsVariation <VariationContent>(p.Target)) .Select(a => CreateVariationViewModel(ContentLoader.Get <VariationContent>(a.Target))); return(productViewModels); }
private LazyProductViewModelCollection CreateLazyRelatedProductContentViewModels(CatalogContentBase catalogContent, string associationType) { return(new LazyProductViewModelCollection(() => { IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink); IEnumerable <IProductViewModel <ProductContent> > productViewModels = Enumerable.Where(associations, p => p.Group.Name.Equals(associationType) && IsProduct <ProductContent>(p.Target)) .Select(a => CreateProductViewModel(ContentLoader.Get <ProductContent>(a.Target))); return productViewModels; })); }
public ContentArea CreateRelatedProductsContentArea(EntryContentBase catalogContent, string associationType) { IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink); ContentArea relatedEntriesCA = new ContentArea(); List <EntryContentBase> relatedEntires = Enumerable.Where(associations, p => p.Group.Name.Equals(associationType)) .Select(a => ContentLoader.Get <EntryContentBase>(a.Target)).ToList(); foreach (var relatedEntire in relatedEntires) { ContentAreaItem caItem = new ContentAreaItem(); caItem.ContentLink = relatedEntire.ContentLink; relatedEntriesCA.Items.Add(caItem); } return(relatedEntriesCA); }
public ContentArea CreateRelatedProductsContentArea(EntryContentBase catalogContent, string associationType) { IEnumerable <Association> associations = LinksRepository.GetAssociations(catalogContent.ContentLink); var relatedEntires = associations.Where(p => p.Group.Name.Equals(associationType)) .Where(x => x.Target != null && x.Target != ContentReference.EmptyReference) .Select(x => ContentLoader.Get <EntryContentBase>(x.Target)); var relatedEntriesCa = new ContentArea(); foreach (var relatedEntire in relatedEntires) { ContentAreaItem caItem = new ContentAreaItem(); caItem.ContentLink = relatedEntire.ContentLink; relatedEntriesCa.Items.Add(caItem); } return(relatedEntriesCa); }