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 List <DynamicContentFolder> LoadFoldersRecursive(DynamicContentFolder folder)
        {
            var retVal          = new List <DynamicContentFolder>();
            var childrenFolders = _dynamicContentSearchService.SearchFolders(new DynamicContentFolderSearchCriteria {
                FolderId = folder?.Id, Take = int.MaxValue
            }).Results.ToList();

            foreach (var childFolder in childrenFolders)
            {
                retVal.Add(childFolder);
                retVal.AddRange(LoadFoldersRecursive(childFolder));
            }
            return(retVal);
        }
 protected virtual GenericSearchResult <DynamicContentFolder> LoadFolders(DynamicContentFolderSearchCriteria criteria)
 {
     return(_dynamicContentSearchService.SearchFolders(criteria));
 }