private IQueryable <Role> CreateQuery(SearchRolesQuery query) { var dbQuery = _dbContext .Roles .AsNoTracking() .AsQueryable(); if (!string.IsNullOrEmpty(query.UserAreaCode)) { dbQuery = dbQuery .Where(r => r.UserAreaCode == query.UserAreaCode); } if (query.ExcludeAnonymous) { dbQuery = dbQuery .Where(r => r.RoleCode != AnonymousRole.AnonymousRoleCode); } if (!string.IsNullOrEmpty(query.Text)) { var text = query.Text.Trim(); dbQuery = dbQuery.Where(r => r.Title.Contains(text)) .OrderByDescending(r => r.Title.StartsWith(text)) .ThenByDescending(r => r.Title); } else { dbQuery = dbQuery .OrderBy(r => r.UserArea.Name) .ThenBy(r => r.Title); } return(dbQuery); }
public async Task <PagedQueryResult <RoleMicroSummary> > ExecuteAsync(SearchRolesQuery query, IExecutionContext executionContext) { CheckRolePermission(query, executionContext); var result = await CreateQuery(query).ToPagedResultAsync(query); return(result); }
public async Task <PagedQueryResult <RoleMicroSummary> > ExecuteAsync(SearchRolesQuery query, IExecutionContext executionContext) { var dbPagedResult = await CreateQuery(query).ToPagedResultAsync(query); var mappedResults = dbPagedResult .Items .Select(_roleMicroSummaryMapper.Map); return(dbPagedResult.ChangeType(mappedResults)); }
/// <summary> /// Seaches roles based on simple filter criteria and returns a paged result. /// </summary> /// <param name="query">Search 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 <PagedQueryResult <RoleMicroSummary> > SearchRolesAsync(SearchRolesQuery query, IExecutionContext executionContext = null) { return(_queryExecutor.ExecuteAsync(query, executionContext)); }
public IContentRepositoryQueryContext <PagedQueryResult <RoleMicroSummary> > AsMicroSummaries(SearchRolesQuery query) { return(ContentRepositoryQueryContextFactory.Create(query, ExtendableContentRepository)); }
public IEnumerable <IPermissionApplication> GetPermissions(SearchRolesQuery command) { yield return(new RoleReadPermission()); }
public Task <PagedQueryResult <RoleMicroSummary> > AsMicroSummariesAsync(SearchRolesQuery query) { return(ExtendableContentRepository.ExecuteQueryAsync(query)); }
private void CheckRolePermission(SearchRolesQuery query, IExecutionContext executionContext) { }