Esempio n. 1
0
        public async Task <ActionResult <DynamicContentListEntrySearchResult> > DynamicContentPlaceListEntriesSearch([FromBody] coreModel.DynamicContentPlaceSearchCriteria criteria)
        {
            var result = AbstractTypeFactory <DynamicContentListEntrySearchResult> .TryCreateInstance();

            var folderSearchCriteria = new coreModel.DynamicContentFolderSearchCriteria
            {
                FolderId = criteria.FolderId,
                Keyword  = criteria.Keyword,
                Take     = criteria.Take,
                Skip     = criteria.Skip,
                Sort     = criteria.Sort
            };

            var foldersSearchResult = await _folderSearchService.SearchFoldersAsync(folderSearchCriteria);

            var folderSkip = Math.Min(foldersSearchResult.TotalCount, criteria.Skip);
            var folderTake = Math.Min(criteria.Take, Math.Max(0, foldersSearchResult.TotalCount - criteria.Skip));

            result.TotalCount += foldersSearchResult.TotalCount;
            result.Results.AddRange(foldersSearchResult.Results.Skip(folderSkip).Take(folderTake));

            criteria.Skip -= folderSkip;
            criteria.Take -= folderTake;

            var placesSearchResult = await _contentPlacesSearchService.SearchContentPlacesAsync(criteria);

            result.TotalCount += placesSearchResult.TotalCount;
            result.Results.AddRange(placesSearchResult.Results);

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <ActionResult <DynamicContentPlaceSearchResult> > DynamicContentPlacesSearch([FromBody] coreModel.DynamicContentPlaceSearchCriteria criteria)
        {
            var placesSearchResult = await _contentPlacesSearchService.SearchContentPlacesAsync(criteria);

            return(Ok(placesSearchResult));
        }
        public async Task <ActionResult <GenericSearchResult <coreModel.DynamicContentFolder> > > DynamicContentPlaceListEntriesSearch([FromBody] coreModel.DynamicContentPlaceSearchCriteria criteria)
        {
            var retVal = new GenericSearchResult <coreModel.DynamicContentListEntry>
            {
                Results = new List <coreModel.DynamicContentListEntry>()
            };

            var foldersSearchResult = await _dynamicConentSearchService.SearchFoldersAsync(new coreModel.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));

            retVal.TotalCount += foldersSearchResult.TotalCount;
            retVal.Results.AddRange(foldersSearchResult.Results.Skip(folderSkip).Take(folderTake));

            criteria.Skip = criteria.Skip - folderSkip;
            criteria.Take = criteria.Take - folderTake;

            var placesSearchResult = await _dynamicConentSearchService.SearchContentPlacesAsync(criteria);

            retVal.TotalCount += placesSearchResult.TotalCount;
            retVal.Results.AddRange(placesSearchResult.Results);

            return(Ok(retVal));
        }