Ejemplo n.º 1
0
        public static List<SamsungVariantVM> GetAllVariantsForAllProducts()
        {
            var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
            var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
            CatalogDto dto = ServiceLocator.Current.GetInstance<ICatalogSystem>().GetCatalogDto();

            ContentReference catalogLink = referenceConverter.GetContentLink(dto.Catalog.First().CatalogId,
                CatalogContentType.Catalog, 0);
            IEnumerable<NodeContent> topCatalogNodes = contentLoader.GetChildren<NodeContent>(catalogLink).ToList();
            IEnumerable<SamsungProduct> topCategoryNodes =
                contentLoader.GetChildren<SamsungProduct>(topCatalogNodes.First().ContentLink).ToList();

            List<SamsungVariantVM> variantsList = new List<SamsungVariantVM>();
            foreach (var item in topCategoryNodes)
            {
                var itemId = referenceConverter.GetObjectId(item.ContentLink);
                var productLink = referenceConverter.GetContentLink(itemId, CatalogContentType.CatalogEntry, 0);
                var productContent = contentLoader.Get<CatalogContentBase>(productLink);
                var prodCurrent = productContent.ContentLink;
                var linksRepository = ServiceLocator.Current.GetInstance<ILinksRepository>();
                var allRelations = linksRepository.GetRelationsBySource(prodCurrent);
                var variations = allRelations.OfType<ProductVariation>().ToList();

                foreach (var variant in variations)
                {
                    var vartiant = contentLoader.Get<SamsungVariant>(variant.Target);
                    var variantVM = new SamsungVariantVM(vartiant);
                    variantsList.Add(variantVM);
                }
            }

            return variantsList;
        }
Ejemplo n.º 2
0
 public static SamsungVariantVM GetAVariantVM(ContentReference contentReference)
 {
     var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
     var item = contentLoader.Get<CatalogContentBase>(contentReference);
     var variationRef = item.ContentLink;
     var variation = contentLoader.Get<SamsungVariant>(variationRef);
     var variantVM = new SamsungVariantVM(variation);
     //  variantVM.
     AssetsForVariant(contentReference);
     return variantVM;
 }