コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task <PagedQueryResult <RoleMicroSummary> > ExecuteAsync(SearchRolesQuery query, IExecutionContext executionContext)
        {
            CheckRolePermission(query, executionContext);
            var result = await CreateQuery(query).ToPagedResultAsync(query);

            return(result);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 /// <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));
 }
コード例 #5
0
 public IContentRepositoryQueryContext <PagedQueryResult <RoleMicroSummary> > AsMicroSummaries(SearchRolesQuery query)
 {
     return(ContentRepositoryQueryContextFactory.Create(query, ExtendableContentRepository));
 }
コード例 #6
0
 public IEnumerable <IPermissionApplication> GetPermissions(SearchRolesQuery command)
 {
     yield return(new RoleReadPermission());
 }
コード例 #7
0
 public Task <PagedQueryResult <RoleMicroSummary> > AsMicroSummariesAsync(SearchRolesQuery query)
 {
     return(ExtendableContentRepository.ExecuteQueryAsync(query));
 }
コード例 #8
0
 private void CheckRolePermission(SearchRolesQuery query, IExecutionContext executionContext)
 {
 }