public async Task <IActionResult> Index(PagedQuery input)
        {
            var queryable   = _dbContext.IdentityResources.AsQueryable().OrderBy(x => x.Created);
            var queryResult = await queryable.ToPagedListAsync(input.GetPage(), input.GetSize());

            var ids = await queryResult.Select(x => x.Id).ToListAsync();

            var claims = _dbContext.IdentityClaims.Where(x => ids.Contains(x.IdentityResourceId))
                         .ToList().GroupBy(x => x.IdentityResourceId).ToDictionary(g => g.Key);
            var viewModel = new StaticPagedList <ListIdentityResourceItemViewModel>(queryResult.Select(x =>
                                                                                                       new ListIdentityResourceItemViewModel
            {
                Name                    = x.Name,
                DisplayName             = x.DisplayName,
                Description             = x.Description,
                Emphasize               = x.Emphasize,
                Enabled                 = x.Enabled,
                Required                = x.Required,
                Id                      = x.Id,
                ShowInDiscoveryDocument = x.ShowInDiscoveryDocument,
                UserClaims              = !claims.ContainsKey(x.Id)
                            ? ""
                            : string.Join(" ", claims[x.Id].Select(ic => ic.Type))
            }), queryResult.PageNumber,
                                                                                    queryResult.PageSize, queryResult.TotalItemCount);

            return(View(viewModel));
        }
示例#2
0
        public async Task <IActionResult> Index(PagedQuery input)
        {
            var queryResult = await _dbContext.Clients
                              .Include(x => x.AllowedGrantTypes)
                              .Include(x => x.RedirectUris)
                              .Include(x => x.PostLogoutRedirectUris)
                              .Include(x => x.AllowedScopes)
                              .Include(x => x.ClientSecrets)
                              .Include(x => x.Claims)
                              .Include(x => x.IdentityProviderRestrictions)
                              .Include(x => x.AllowedCorsOrigins)
                              .Include(x => x.Properties)
                              .AsNoTracking().Select(x => new ListClientItemViewModel
            {
                Id                = x.Id,
                ClientId          = x.ClientId,
                ClientName        = x.ClientName,
                AllowedScopes     = string.Join(" ", x.AllowedScopes.Select(s => s.Scope)),
                AllowedGrantTypes = string.Join(" ", x.AllowedGrantTypes.Select(t => t.GrantType))
            })
                              .ToPagedListAsync(input.GetPage(), input.GetSize());

            return(View(queryResult));
        }