public IEnumerable <Review> GetReviews(IEnumerable <IRatingPage> contentReferences)
        {
            var crs = contentReferences.OfType <PageData>().Select(x => x.ContentLink);

            var assetFolders = new List <ContentAssetFolder>();

            foreach (var r in crs)
            {
                assetFolders.Add(contentAssetHelper.GetAssetFolder(r));
            }

            //var items = _loader.GetItems(assetFolders.Select(x => x.ContentLink), CultureInfo.CurrentUICulture);

            var items = new List <Review>();

            foreach (var item in assetFolders)
            {
                items.AddRange(_loader.GetChildren <Review>(item.ContentLink, CultureInfo.CurrentUICulture));
            }

            return(items);
        }
 private static void DeleteContentInAssetFolders(IEnumerable <ContentReference> contentReferences, ContentAssetHelper assetHelper,
                                                 IContentRepository repo, StringBuilder sb, IBlobFactory blobFactory)
 {
     foreach (ContentReference reference in contentReferences)
     {
         ContentAssetFolder folder = assetHelper.GetAssetFolder(reference);
         if (folder != null && folder.ContentLink != null)
         {
             var folderContents = repo.GetDescendents(folder.ContentLink);
             DeleteBlobs(folderContents, repo, sb, blobFactory);
         }
     }
 }
        //TODO: This should take in id, and type. Then it can be used on both commerce products and pagedata

        public ReviewResult Get(int id)
        {
            ReviewResult reviewResult = new ReviewResult();

            reviewResult.AverageReview        = 0;
            reviewResult.TotalNumberOfReviews = 0;
            reviewResult.Reviews = new List <ReviewData>();
            ContentReference contentLink = _referenceConverter.GetContentLink(id, CatalogContentType.CatalogEntry, 0);
            var contentAssetFolder       = _contentAssetHelper.GetAssetFolder(contentLink);

            if (contentAssetFolder == null)
            {
                return(reviewResult);
            }
            List <Review> reviews = new List <Review>();

            if (Language == null)
            {
                reviews = _contentRepository.GetChildren <Review>(contentAssetFolder.ContentLink).ToList();
            }
            else
            {
                reviews = _contentRepository.GetChildren <Review>(contentAssetFolder.ContentLink, new CultureInfo(Language)).ToList();
            }


            if (reviews.Any())
            {
                reviewResult.Reviews = reviews.Select(x => new ReviewData
                {
                    ContentId  = x.ContentId,
                    Rating     = x.Rating,
                    Heading    = x.Heading,
                    Text       = x.Text,
                    UserName   = x.UserDisplayName,
                    ReviewDate = x.ReviewDate
                }).OrderByDescending(y => y.ReviewDate).ToList();
                reviewResult.TotalNumberOfReviews = reviewResult.Reviews.Count;
                var average = reviewResult.Reviews.Average(x => x.Rating);
                average = average * 2;
                average = Math.Round(average, MidpointRounding.AwayFromZero);
                average = average / 2;
                reviewResult.AverageReview = average;
            }

            return(reviewResult);
        }
 private static void DeleteContentInAssetFolders(IEnumerable<ContentReference> contentReferences, ContentAssetHelper assetHelper,
     IContentRepository repo, StringBuilder sb, BlobFactory blobFactory)
 {
     foreach (ContentReference reference in contentReferences)
     {
         ContentAssetFolder folder = assetHelper.GetAssetFolder(reference);
         if (folder != null && folder.ContentLink != null)
         {
             var folderContents = repo.GetDescendents(folder.ContentLink);
             DeleteBlobs(folderContents, repo, sb, blobFactory);
         }
     }
 }