public IHttpActionResult DynamicContentPlaceListEntriesSearch(DynamicContentPlaceSearchCriteria criteria) { var retVal = new GenericSearchResult <webModel.DynamicContentListEntry>(); retVal.Results = new List <webModel.DynamicContentListEntry>(); var foldersSearchResult = _dynamicConentSearchService.SearchFolders(new DynamicContentFolderSearchCriteria { FolderId = criteria.FolderId, Keyword = criteria.Keyword, Take = criteria.Take, Skip = criteria.Skip, Sort = criteria.Sort }); var folderSkip = Math.Min(foldersSearchResult.TotalCount, criteria.Skip); var folderTake = Math.Min(criteria.Take, Math.Max(0, foldersSearchResult.TotalCount - criteria.Skip)); var folders = foldersSearchResult.Results.Skip(folderSkip).Take(folderTake).Select(x => x.ToWebModel()); retVal.TotalCount += foldersSearchResult.TotalCount; retVal.Results.AddRange(folders); criteria.Skip = criteria.Skip - folderSkip; criteria.Take = criteria.Take - folderTake; var placesSearchResult = _dynamicConentSearchService.SearchContentPlaces(criteria); retVal.TotalCount += placesSearchResult.TotalCount; retVal.Results.AddRange(placesSearchResult.Results.Select(x => x.ToWebModel())); return(Ok(retVal)); }
private BackupObject GetBackupObject(Action <ExportImportProgressInfo> progressCallback) { var result = new BackupObject(); var progressInfo = new ExportImportProgressInfo { Description = "Search promotions..." }; progressCallback(progressInfo); var allPromotions = _promotionSearchService.SearchPromotions(new Domain.Marketing.Model.Promotions.Search.PromotionSearchCriteria { Take = int.MaxValue }).Results; progressInfo.Description = String.Format("{0} promotions loading...", allPromotions.Count()); progressCallback(progressInfo); result.Promotions = _promotionService.GetPromotionsByIds(allPromotions.Select(x => x.Id).ToArray()); progressInfo.Description = "Search dynamic content objects..."; progressCallback(progressInfo); progressInfo.Description = String.Format("Loading folders..."); progressCallback(progressInfo); result.ContentFolders = LoadFoldersRecursive(null); progressInfo.Description = String.Format("Loading places..."); progressCallback(progressInfo); result.ContentPlaces = _dynamicContentSearchService.SearchContentPlaces(new DynamicContentPlaceSearchCriteria { Take = int.MaxValue }).Results.ToList(); progressInfo.Description = String.Format("Loading contents..."); progressCallback(progressInfo); result.ContentItems = _dynamicContentSearchService.SearchContentItems(new DynamicContentItemSearchCriteria { Take = int.MaxValue }).Results.ToList(); progressInfo.Description = String.Format("Loading publications..."); progressCallback(progressInfo); result.ContentPublications = _dynamicContentSearchService.SearchContentPublications(new DynamicContentPublicationSearchCriteria { Take = int.MaxValue }).Results.ToList(); progressInfo.Description = String.Format("Loading coupons..."); progressCallback(progressInfo); var couponsTotal = _couponService.SearchCoupons(new CouponSearchCriteria { Take = 0 }).TotalCount; var pageSize = 500; Paginate(couponsTotal, pageSize, (x) => { progressInfo.Description = String.Format($"Loading coupons: {Math.Min(x * pageSize, couponsTotal)} of {couponsTotal} loaded"); progressCallback(progressInfo); result.Coupons.AddRange(_couponService.SearchCoupons(new CouponSearchCriteria { Skip = (x - 1) * pageSize, Take = pageSize }).Results); }); progressInfo.Description = String.Format("Loading usages..."); progressCallback(progressInfo); var usagesTotal = _usageService.SearchUsages(new PromotionUsageSearchCriteria { Take = 0 }).TotalCount; Paginate(usagesTotal, pageSize, (x) => { progressInfo.Description = String.Format($"Loading usages: {Math.Min(x * pageSize, usagesTotal)} of {usagesTotal} loaded"); progressCallback(progressInfo); result.Usages.AddRange(_usageService.SearchUsages(new PromotionUsageSearchCriteria { Skip = (x - 1) * pageSize, Take = pageSize }).Results); }); return(result); }
protected virtual GenericSearchResult <DynamicContentPlace> LoadContentPlaces(DynamicContentPlaceSearchCriteria criteria) { return(_dynamicContentSearchService.SearchContentPlaces(criteria)); }