コード例 #1
0
        public async Task MapAsync(
            PageBlockTypeDisplayModelMapperContext <DocumentDataModel> context,
            PageBlockTypeDisplayModelMapperResult <DocumentDataModel> result
            )
        {
            var documentIds    = context.Items.SelectDistinctModelValuesWithoutEmpty(i => i.DocumentAssetId);
            var documentsQuery = new GetDocumentAssetRenderDetailsByIdRangeQuery(documentIds);
            var documents      = await _queryExecutor.ExecuteAsync(documentsQuery, context.ExecutionContext);

            foreach (var item in context.Items)
            {
                var document = documents.GetOrDefault(item.DataModel.DocumentAssetId);

                var displayModel = new DocumentDisplayModel();
                if (document != null)
                {
                    displayModel.Description = document.Description;
                    displayModel.Title       = document.Title;
                    if (item.DataModel.DownloadMode == DocumentDownloadMode.ForceDownload)
                    {
                        displayModel.Url = _documentAssetRouteLibrary.DocumentAssetDownload(document);
                    }
                    else
                    {
                        displayModel.Url = _documentAssetRouteLibrary.DocumentAsset(document);
                    }
                }

                result.Add(item, displayModel);
            }
        }
コード例 #2
0
 private IQueryable <DocumentAsset> QueryDb(GetDocumentAssetRenderDetailsByIdRangeQuery query)
 {
     return(_dbContext
            .DocumentAssets
            .AsNoTracking()
            .FilterByIds(query.DocumentAssetIds));
 }
コード例 #3
0
        public async Task <IEnumerable <PageBlockTypeDisplayModelMapperOutput> > MapAsync(
            IReadOnlyCollection <PageBlockTypeDisplayModelMapperInput <DocumentDataModel> > inputCollection,
            PublishStatusQuery publishStatusQuery
            )
        {
            var documentIds    = inputCollection.SelectDistinctModelValuesWithoutEmpty(i => i.DocumentAssetId);
            var documentsQuery = new GetDocumentAssetRenderDetailsByIdRangeQuery(documentIds);
            var documents      = await _queryExecutor.ExecuteAsync(documentsQuery);

            var results = new List <PageBlockTypeDisplayModelMapperOutput>(inputCollection.Count);

            foreach (var input in inputCollection)
            {
                var document = documents.GetOrDefault(input.DataModel.DocumentAssetId);

                var output = new DocumentDisplayModel();
                if (document != null)
                {
                    output.Description = document.Description;
                    output.Title       = document.Title;
                    if (input.DataModel.DownloadMode == DocumentDownloadMode.ForceDownload)
                    {
                        output.Url = _documentAssetRouteLibrary.DocumentAssetDownload(document);
                    }
                    else
                    {
                        output.Url = _documentAssetRouteLibrary.DocumentAsset(document);
                    }
                }

                results.Add(input.CreateOutput(output));
            }

            return(results);
        }
コード例 #4
0
        public async Task <IActionResult> Get(
            [FromQuery] SearchDocumentAssetSummariesQuery query,
            [FromQuery] GetDocumentAssetRenderDetailsByIdRangeQuery rangeQuery
            )
        {
            if (rangeQuery != null && rangeQuery.DocumentAssetIds != null)
            {
                var rangeResults = await _queryExecutor.ExecuteAsync(rangeQuery);

                return(_apiResponseHelper.SimpleQueryResponse(this, rangeResults.FilterAndOrderByKeys(rangeQuery.DocumentAssetIds)));
            }

            if (query == null)
            {
                query = new SearchDocumentAssetSummariesQuery();
            }

            var results = await _queryExecutor.ExecuteAsync(query);

            return(_apiResponseHelper.SimpleQueryResponse(this, results));
        }
コード例 #5
0
        public async Task <JsonResult> Get(
            [FromQuery] SearchDocumentAssetSummariesQuery query,
            [FromQuery] GetDocumentAssetRenderDetailsByIdRangeQuery rangeQuery
            )
        {
            if (rangeQuery != null && rangeQuery.DocumentAssetIds != null)
            {
                return(await _apiResponseHelper.RunWithResultAsync(async() =>
                {
                    return await _domainRepository
                    .WithQuery(rangeQuery)
                    .FilterAndOrderByKeys(rangeQuery.DocumentAssetIds)
                    .ExecuteAsync();
                }));
            }

            if (query == null)
            {
                query = new SearchDocumentAssetSummariesQuery();
            }
            ApiPagingHelper.SetDefaultBounds(query);

            return(await _apiResponseHelper.RunQueryAsync(query));
        }
コード例 #6
0
 public IEnumerable <IPermissionApplication> GetPermissions(GetDocumentAssetRenderDetailsByIdRangeQuery query)
 {
     yield return(new DocumentAssetReadPermission());
 }
コード例 #7
0
        public async Task <IDictionary <int, DocumentAssetRenderDetails> > ExecuteAsync(GetDocumentAssetRenderDetailsByIdRangeQuery query, IExecutionContext executionContext)
        {
            var dbResults = await QueryDb(query).ToListAsync();

            var mappedResults = dbResults
                                .Select(_documentAssetRenderDetailsMapper.Map)
                                .ToDictionary(d => d.DocumentAssetId);

            return(mappedResults);
        }
コード例 #8
0
        public IDomainRepositoryQueryContext <IDictionary <int, DocumentAssetRenderDetails> > AsRenderDetails()
        {
            var query = new GetDocumentAssetRenderDetailsByIdRangeQuery(_documentAssetIds);

            return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository));
        }