public IEnumerable <IPermissionApplication> GetPermissions(SearchCustomEntitySummariesQuery query) { var definition = _customEntityDefinitionRepository.GetByCode(query.CustomEntityDefinitionCode); EntityNotFoundException.ThrowIfNull(definition, query.CustomEntityDefinitionCode); yield return(new CustomEntityReadPermission(definition)); }
public async Task <JsonResult> GetCustomEntities(string customEntityDefinitionCode, [FromQuery] SearchCustomEntitySummariesQuery query) { if (query == null) { query = new SearchCustomEntitySummariesQuery(); } query.CustomEntityDefinitionCode = customEntityDefinitionCode; ApiPagingHelper.SetDefaultBounds(query); return(await _apiResponseHelper.RunQueryAsync(query)); }
public async Task <IActionResult> Get(string customEntityDefinitionCode, [FromQuery] SearchCustomEntitySummariesQuery query) { if (query == null) { query = new SearchCustomEntitySummariesQuery(); } query.CustomEntityDefinitionCode = customEntityDefinitionCode; var results = await _queryExecutor.ExecuteAsync(query); return(_apiResponseHelper.SimpleQueryResponse(this, results)); }
public async Task <PagedQueryResult <CustomEntitySummary> > ExecuteAsync(SearchCustomEntitySummariesQuery query, IExecutionContext executionContext) { var definition = _customEntityDefinitionRepository.GetByCode(query.CustomEntityDefinitionCode); EntityNotFoundException.ThrowIfNull(definition, query.CustomEntityDefinitionCode); // Get Main Query var dbPagedResult = await RunQueryAsync(query, definition, executionContext); var mappedResult = await _customEntitySummaryMapper.MapAsync(dbPagedResult.Items, executionContext); return(dbPagedResult.ChangeType(mappedResult)); }
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); }
public async Task <JsonResult> GetCustomEntities(string customEntityDefinitionCode, [FromQuery] SearchCustomEntitySummariesQuery query) { if (query == null) { query = new SearchCustomEntitySummariesQuery(); } query.CustomEntityDefinitionCode = customEntityDefinitionCode; ApiPagingHelper.SetDefaultBounds(query); var results = await _queryExecutor.ExecuteAsync(query); return(_apiResponseHelper.SimpleQueryResponse(results)); }
private Task <PagedQueryResult <CustomEntityPublishStatusQuery> > RunQueryAsync( SearchCustomEntitySummariesQuery query, ICustomEntityDefinition definition, IExecutionContext executionContext ) { var dbQuery = _dbContext .CustomEntityPublishStatusQueries .AsNoTracking() .Include(v => v.CustomEntityVersion) .ThenInclude(v => v.Creator) .Include(v => v.CustomEntity) .ThenInclude(c => c.Creator) .FilterActive() .FilterByDate(c => c.CustomEntity.CreateDate, query.CreatedAfter, query.CreatedBefore) .FilterByStatus(PublishStatusQuery.Latest, executionContext.ExecutionDate) .FilterByCustomEntityDefinitionCode(query.CustomEntityDefinitionCode); // Filter by locale if (query.LocaleId > 0 && definition.HasLocale) { dbQuery = dbQuery.Where(p => p.CustomEntity.LocaleId == query.LocaleId); } else if (query.InterpretNullLocaleAsNone) { dbQuery = dbQuery.Where(p => !p.CustomEntity.LocaleId.HasValue); } if (!string.IsNullOrWhiteSpace(query.Text)) { dbQuery = dbQuery .Where(e => e.CustomEntityVersion.Title.Contains(query.Text) || e.CustomEntityVersion.SerializedData.Contains(query.Text)) .OrderByDescending(e => e.CustomEntityVersion.Title == query.Text) .ThenByDescending(e => e.CustomEntityVersion.Title.Contains(query.Text)); } else { dbQuery = dbQuery .SortBy(definition, CustomEntityQuerySortType.Default); } var dbPagedResult = dbQuery.ToPagedResultAsync(query); return(dbPagedResult); }
public async Task <IHttpActionResult> Get([FromUri] SearchCustomEntitySummariesQuery query, [FromUri] GetByIdRangeQuery <CustomEntitySummary> rangeQuery) { if (rangeQuery != null && rangeQuery.Ids != null) { var rangeResults = await _queryExecutor.ExecuteAsync(rangeQuery); return(_apiResponseHelper.SimpleQueryResponse(this, rangeResults.ToFilteredAndOrderedCollection(rangeQuery.Ids))); } if (query == null) { query = new SearchCustomEntitySummariesQuery(); } var results = await _queryExecutor.ExecuteAsync(query); return(_apiResponseHelper.SimpleQueryResponse(this, results)); }
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 IEnumerable <IPermissionApplication> GetPermissions(SearchCustomEntitySummariesQuery query) { var definition = _customEntityDefinitionRepository.GetRequiredByCode(query.CustomEntityDefinitionCode); yield return(new CustomEntityReadPermission(definition)); }
public IDomainRepositoryQueryContext <PagedQueryResult <CustomEntitySummary> > AsSummaries(SearchCustomEntitySummariesQuery query) { return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository)); }