Esempio n. 1
0
        public async Task <PagedQueryResult <DocumentAssetSummary> > ExecuteAsync(SearchDocumentAssetSummariesQuery query, IExecutionContext executionContext)
        {
            var dbQuery = _dbContext
                          .DocumentAssets
                          .AsNoTracking()
                          .Include(a => a.Creator)
                          .Include(a => a.Updater)
                          .Include(a => a.DocumentAssetTags)
                          .ThenInclude(a => a.Tag)
                          .Where(i => !i.IsDeleted);

            // Filter by tags
            if (!string.IsNullOrEmpty(query.Tags))
            {
                var tags = TagParser.Split(query.Tags).ToList();

                foreach (string tag in tags)
                {
                    // See http://stackoverflow.com/a/7288269/486434 for why this is copied into a new variable
                    string localTag = tag;

                    dbQuery = dbQuery.Where(p => p.DocumentAssetTags
                                            .Select(t => t.Tag.TagText)
                                            .Contains(localTag)
                                            );
                }
            }

            // Filter multple extensions
            if (!string.IsNullOrEmpty(query.FileExtensions))
            {
                var fileExtensions = query.FileExtensions.Split(new char[] { '.', ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                dbQuery = dbQuery.Where(p => fileExtensions.Contains(p.FileExtension));
            }

            if (!string.IsNullOrWhiteSpace(query.FileExtension))
            {
                var formattedExtension = query.FileExtension.TrimStart('.');
                dbQuery = dbQuery.Where(p => p.FileExtension == formattedExtension);
            }

            var dbPagesResults = await dbQuery
                                 .OrderByDescending(p => p.CreateDate)
                                 .ToPagedResultAsync(query);

            var mappedResults = dbPagesResults
                                .Items
                                .Select(_documentAssetSummaryMapper.Map);

            return(dbPagesResults.ChangeType(mappedResults));
        }
Esempio n. 2
0
 public Task <PagedQueryResult <DocumentAssetSummary> > SearchDocumentAssetSummariesAsync(SearchDocumentAssetSummariesQuery query, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.ExecuteAsync(query, executionContext));
 }
 public IEnumerable <IPermissionApplication> GetPermissions(SearchDocumentAssetSummariesQuery query)
 {
     yield return(new DocumentAssetReadPermission());
 }
Esempio n. 4
0
 public Task <PagedQueryResult <DocumentAssetSummary> > AsSummariesAsync(SearchDocumentAssetSummariesQuery query)
 {
     return(ExtendableContentRepository.ExecuteQueryAsync(query));
 }
 public IContentRepositoryQueryContext <PagedQueryResult <DocumentAssetSummary> > AsSummaries(SearchDocumentAssetSummariesQuery query)
 {
     return(ContentRepositoryQueryContextFactory.Create(query, ExtendableContentRepository));
 }