public async Task <IDictionary <int, CustomEntitySummary> > ExecuteAsync(GetCustomEntitySummariesByIdRangeQuery query, IExecutionContext executionContext) { var dbResults = await QueryAsync(query, executionContext); // Validation permissions var definitionCodes = dbResults.Select(r => r.CustomEntity.CustomEntityDefinitionCode); _permissionValidationService.EnforceCustomEntityPermission <CustomEntityReadPermission>(definitionCodes, executionContext.UserContext); var mappedResults = await _customEntitySummaryMapper.MapAsync(dbResults, executionContext); return(mappedResults.ToDictionary(r => r.CustomEntityId)); }
private async Task <List <CustomEntityPublishStatusQuery> > QueryAsync(GetCustomEntitySummariesByIdRangeQuery query, IExecutionContext executionContext) { var dbResults = await _dbContext .CustomEntityPublishStatusQueries .AsNoTracking() .Include(e => e.CustomEntityVersion) .ThenInclude(e => e.Creator) .Include(e => e.CustomEntity) .ThenInclude(e => e.Creator) .Where(v => query.CustomEntityIds.Contains(v.CustomEntityId)) .FilterActive() .FilterByStatus(PublishStatusQuery.Latest, executionContext.ExecutionDate) .ToListAsync(); return(dbResults); }
public IDomainRepositoryQueryContext <IDictionary <int, CustomEntitySummary> > AsSummaries() { var query = new GetCustomEntitySummariesByIdRangeQuery(_customEntityIds); return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository)); }
public async Task <JsonResult> Get([FromQuery] SearchCustomEntitySummariesQuery query, [FromQuery] GetCustomEntitySummariesByIdRangeQuery rangeQuery) { if (rangeQuery != null && rangeQuery.CustomEntityIds != null) { var rangeResults = await _queryExecutor.ExecuteAsync(rangeQuery); return(_apiResponseHelper.SimpleQueryResponse(rangeResults.FilterAndOrderByKeys(rangeQuery.CustomEntityIds))); } if (query == null) { query = new SearchCustomEntitySummariesQuery(); } ApiPagingHelper.SetDefaultBounds(query); var results = await _queryExecutor.ExecuteAsync(query); return(_apiResponseHelper.SimpleQueryResponse(results)); }
public async Task <JsonResult> Get([FromQuery] SearchCustomEntitySummariesQuery query, [FromQuery] GetCustomEntitySummariesByIdRangeQuery rangeQuery) { if (rangeQuery != null && rangeQuery.CustomEntityIds != null) { return(await _apiResponseHelper.RunWithResultAsync(async() => { return await _domainRepository .WithQuery(rangeQuery) .FilterAndOrderByKeys(rangeQuery.CustomEntityIds) .ExecuteAsync(); })); } if (query == null) { query = new SearchCustomEntitySummariesQuery(); } ApiPagingHelper.SetDefaultBounds(query); return(await _apiResponseHelper.RunQueryAsync(query)); }
public async Task<IActionResult> Get([FromQuery] SearchCustomEntitySummariesQuery query, [FromQuery] GetCustomEntitySummariesByIdRangeQuery rangeQuery) { if (rangeQuery != null && rangeQuery.CustomEntityIds != null) { var rangeResults = await _queryExecutor.ExecuteAsync(rangeQuery); return _apiResponseHelper.SimpleQueryResponse(this, rangeResults.FilterAndOrderByKeys(rangeQuery.CustomEntityIds)); } if (query == null) query = new SearchCustomEntitySummariesQuery(); var results = await _queryExecutor.ExecuteAsync(query); return _apiResponseHelper.SimpleQueryResponse(this, results); }