Ejemplo n.º 1
0
        public async Task <IDictionary <int, PageRenderSummary> > ExecuteAsync(GetPageRenderSummariesByIdRangeQuery query, IExecutionContext executionContext)
        {
            var dbPages = await GetPagesAsync(query, executionContext);

            var allPageIds      = dbPages.Select(p => p.PageId);
            var pageRoutesQuery = new GetPageRoutesByIdRangeQuery(allPageIds);
            var pageRoutes      = await _queryExecutor.ExecuteAsync(pageRoutesQuery, executionContext);

            var pages = dbPages
                        .Select(p => _pageRenderSummaryMapper.Map <PageRenderSummary>(p, pageRoutes))
                        .ToList();

            return(pages.ToDictionary(d => d.PageId));
        }
Ejemplo n.º 2
0
        private async Task <List <PageVersion> > GetPagesAsync(GetPageRenderSummariesByIdRangeQuery query, IExecutionContext executionContext)
        {
            if (query.PublishStatus == PublishStatusQuery.SpecificVersion)
            {
                throw new InvalidOperationException($"PublishStatusQuery.SpecificVersion not supported in ${nameof(GetPageRenderSummariesByIdRangeQuery)}");
            }

            var dbResults = await _dbContext
                            .PagePublishStatusQueries
                            .AsNoTracking()
                            .FilterActive()
                            .FilterByStatus(query.PublishStatus, executionContext.ExecutionDate)
                            .Where(v => query.PageIds.Contains(v.PageId))
                            .Select(r => r.PageVersion)
                            .Include(v => v.OpenGraphImageAsset)
                            .ToListAsync();

            return(dbResults);
        }
        public Task <IDictionary <int, PageRenderSummary> > AsRenderSummariesAsync(PublishStatusQuery?publishStatus = null)
        {
            var query = new GetPageRenderSummariesByIdRangeQuery(_pageIds, publishStatus);

            return(ExtendableContentRepository.ExecuteQueryAsync(query));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets a range of pages by a set of id, projected as a PageRenderSummary, which is
 /// a lighter weight projection designed for rendering to a site when the
 /// templates, region and block data is not required. The results are
 /// version-sensitive and defaults to returning published versions only, but
 /// this behavior can be controlled by the publishStatus query property.
 /// </summary>
 /// <param name="query">Query parameters</param>
 /// <param name="executionContext">Optional execution context to use when executing the query. Useful if you need to temporarily elevate your permission level.</param>
 public Task <IDictionary <int, PageRenderSummary> > GetPageRenderSummariesByIdRangeAsync(GetPageRenderSummariesByIdRangeQuery query, IExecutionContext executionContext = null)
 {
     return(_queryExecutor.ExecuteAsync(query, executionContext));
 }
Ejemplo n.º 5
0
 public IEnumerable <IPermissionApplication> GetPermissions(GetPageRenderSummariesByIdRangeQuery query)
 {
     yield return(new PageReadPermission());
 }
Ejemplo n.º 6
0
        public IContentRepositoryQueryContext <IDictionary <int, PageRenderSummary> > AsRenderSummaries(PublishStatusQuery?publishStatus = null)
        {
            var query = new GetPageRenderSummariesByIdRangeQuery(_pageIds, publishStatus);

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