private ContentBucketList GetAllBuckets() { ContentBucketList allBuckets = new ContentBucketList(); allBuckets.Items = new List <ContentBucketResponse>(); ContentBucketList buckets = SearchBuckets(); int offset = 0; int page = 0; bool isDoneTraversing = false; while (!isDoneTraversing) { allBuckets.Items.AddRange(buckets.Items); if (buckets.Items.Count == DEFAULT_COUNT) { offset += DEFAULT_COUNT; buckets = SearchBuckets(offset); page++; } else { isDoneTraversing = true; } } return(allBuckets); }
private ContentBucketList SearchBuckets(int offset) { ContentBucketList buckets = _client.Buckets.SearchBuckets(new BucketSearchRequest { Count = DEFAULT_COUNT, Offset = offset }); return(buckets); }
private ContentList GetAllContentForBuckets(ContentBucketList buckets) { ContentList allContent = new ContentList(); allContent.Items = new List <ContentResponse>(); foreach (ContentBucketResponse bucket in buckets.Items) { if (bucket.Type != ContentType.Image) { ContentList contentForBucket = GetAllContentForBucket(bucket.Slug); allContent.Items.AddRange(contentForBucket.Items); } } return(allContent); }
// // GET: /License/DisplayBuckets public ActionResult DisplayBuckets() { ContentBucketList buckets = _client.Buckets.SearchBuckets(new BucketSearchRequest { Count = DEFAULT_COUNT }); //Trim the results if this is a public demo. if (IsPublicDemo()) { List <ContentBucketResponse> trimmedList = new List <ContentBucketResponse>(); trimmedList.AddRange(buckets.Items.Take(TRIM_COUNT)); buckets.Items = trimmedList; } return(View(buckets)); }
private List <ContentReferenceModel> GetContentForDownload() { //Get all items from buckets ContentBucketList allBuckets = GetAllBuckets(); ContentList contentFromBuckets = GetAllContentForBuckets(allBuckets); //Get all items from collection CollectionListResponse collections = GetAllCollections(); List <CollectionItemResponse> collectionItemResponses = GetAllContentForCollections(collections); //Convert and combine everything into single model. List <ContentReferenceModel> contentToDownload = new List <ContentReferenceModel>(); contentToDownload.AddRange(ConvertToContentModel(contentFromBuckets)); contentToDownload.AddRange(ConvertToContentModel(collectionItemResponses)); //Remove all duplicates. contentToDownload = RemoveDuplicates(contentToDownload); return(contentToDownload); }
private List <ContentReferenceModel> GetContentForPublicDemoDownload() { List <ContentReferenceModel> trimmedContentToDownload = new List <ContentReferenceModel>(); ContentBucketList buckets = SearchBuckets(); if (buckets.Items.Count > 0) { ContentList contentList = new ContentList(); contentList.Items = new List <ContentResponse>(); for (int i = 0; i < buckets.Items.Count && i < TRIM_COUNT; i++) { contentList.Items.AddRange(SearchContent(buckets.Items[i].Slug).Items); } List <ContentReferenceModel> contentForBucket = ConvertToContentModel(contentList); //Remove all duplicates. contentForBucket = RemoveDuplicates(contentForBucket); //Trim for public demo. trimmedContentToDownload.AddRange(contentForBucket.Take(TRIM_COUNT)); } return(trimmedContentToDownload); }