public IEnumerable<IPermissionApplication> GetPermissions(SearchCustomEntitiesQuery query) { var definition = _customEntityDefinitionRepository.GetByCode(query.CustomEntityDefinitionCode); EntityNotFoundException.ThrowIfNull(definition, query.CustomEntityDefinitionCode); yield return new CustomEntityReadPermission(definition); }
public async Task<PagedQueryResult<CustomEntityRenderSummary>> ExecuteAsync(SearchCustomEntitiesQuery query, IExecutionContext executionContext) { var dbPagedResult = await GetQueryAsync(query, executionContext); var results = await _customEntityRenderSummaryMapper.MapAsync(dbPagedResult.Items, executionContext); return dbPagedResult.ChangeType(results); }
private async Task<PagedQueryResult<CustomEntityVersion>> GetQueryAsync(SearchCustomEntitiesQuery query, IExecutionContext executionContext) { var definition = _customEntityDefinitionRepository.GetByCode(query.CustomEntityDefinitionCode); EntityNotFoundException.ThrowIfNull(definition, query.CustomEntityDefinitionCode); var dbQuery = _dbContext .CustomEntityPublishStatusQueries .AsNoTracking() .FilterByCustomEntityDefinitionCode(query.CustomEntityDefinitionCode) .FilterActive() .FilterByStatus(query.PublishStatus, executionContext.ExecutionDate); // Filter by locale if (query.LocaleId > 0 && definition.HasLocale) { dbQuery = dbQuery.Where(p => p.CustomEntity.LocaleId == query.LocaleId); } else { dbQuery = dbQuery.Where(p => !p.CustomEntity.LocaleId.HasValue); } var baseExpression = _searchSpecificationMapper.Map(query.Specifications); if (baseExpression != null) { var jsonValueModifier = new JsonValueModifier<CustomEntityPublishStatusQuery>(c => c.CustomEntityVersion.SerializedData); var queryResult = jsonValueModifier.Visit(baseExpression); var translatedQuery = (Expression<Func<CustomEntityPublishStatusQuery, bool>>)queryResult ; dbQuery = dbQuery.Where(translatedQuery); } var dbPagedResult = await dbQuery .SortBy(definition, query.SortBy, query.SortDirection) .Select(p => p.CustomEntityVersion) .Include(e => e.CustomEntity) .ToPagedResultAsync(query); return dbPagedResult; }
public Task <PagedQueryResult <CustomEntityRenderSummary> > SearchCustomEntityRenderSummariesAsync(SearchCustomEntitiesQuery query, IExecutionContext executionContext = null) { return(_queryExecutor.ExecuteAsync(query, executionContext)); }