コード例 #1
0
        public async Task <PagedQueryResult <PageTemplateSummary> > ExecuteAsync(SearchPageTemplateSummariesQuery query, IExecutionContext executionContext)
        {
            var dbPagedResult = await CreateQuery(query).ToPagedResultAsync(query);

            var allPageTemplateIds = dbPagedResult
                                     .Items
                                     .Select(p => p.PageTemplate.PageTemplateId)
                                     .ToList();

            var templatePageCounts = await GetPageCounts(allPageTemplateIds);

            Dictionary <int, int> pageRegionCounts = await GetTemplateRegionCounts();

            foreach (var dbPagedResultItem in dbPagedResult.Items)
            {
                dbPagedResultItem.NumPages   = templatePageCounts.GetOrDefault(dbPagedResultItem.PageTemplate.PageTemplateId);
                dbPagedResultItem.NumRegions = pageRegionCounts.GetOrDefault(dbPagedResultItem.PageTemplate.PageTemplateId);
            }

            var mappedResults = dbPagedResult
                                .Items
                                .Select(_pageTemplateSummaryMapper.Map);

            return(dbPagedResult.ChangeType(mappedResults));
        }
コード例 #2
0
        private IQueryable <PageTemplateSummaryQueryModel> CreateQuery(SearchPageTemplateSummariesQuery query)
        {
            var dbQuery = _dbContext
                          .PageTemplates
                          .AsNoTracking()
                          .AsQueryable();

            // Filter by group
            if (!string.IsNullOrWhiteSpace(query.Name))
            {
                dbQuery = dbQuery.Where(p => p.FileName.Contains(query.Name) || p.Description.Contains(query.Name));
            }

            return(dbQuery
                   .OrderBy(p => p.FileName)
                   .Select(t => new PageTemplateSummaryQueryModel()
            {
                PageTemplate = t,
                //NumPages = t.PageVersions
                //    .GroupBy(p => p.PageId)
                //    .Count(),
                //NumRegions = t
                //    .PageTemplateRegions
                //    .Count()
            }));
        }
コード例 #3
0
        private IQueryable <PageTemplateSummary> CreateQuery(SearchPageTemplateSummariesQuery query)
        {
            var dbQuery = _dbContext
                          .PageTemplates
                          .AsNoTracking()
                          .AsQueryable();

            // Filter by group
            if (!string.IsNullOrWhiteSpace(query.Name))
            {
                dbQuery = dbQuery.Where(p => p.FileName.Contains(query.Name) || p.Description.Contains(query.Name));
            }

            return(dbQuery
                   .OrderBy(p => p.FileName)
                   .ProjectTo <PageTemplateSummary>());
        }
 public IEnumerable <IPermissionApplication> GetPermissions(SearchPageTemplateSummariesQuery query)
 {
     yield return(new PageTemplateReadPermission());
 }
コード例 #5
0
        public async Task <PagedQueryResult <PageTemplateSummary> > ExecuteAsync(SearchPageTemplateSummariesQuery query, IExecutionContext executionContext)
        {
            var result = await CreateQuery(query).ToPagedResultAsync(query);

            return(result);
        }