private async Task <GrantsViewModel> BuildViewModelAsync() { var grants = await _interaction.GetAllUserGrantsAsync(); var list = new List <GrantViewModel>(); foreach (var grant in grants) { var client = await _clients.FindClientByIdAsync(grant.ClientId); if (client != null) { var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes); var item = new GrantViewModel { ClientId = client.ClientId, ClientName = client.ClientName ?? client.ClientId, ClientLogoUrl = client.LogoUri, ClientUrl = client.ClientUri, Description = grant.Description, Created = grant.CreationTime, Expires = grant.Expiration, IdentityGrantNames = resources.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(), ApiGrantNames = resources.ApiScopes.Select(x => x.DisplayName ?? x.Name).ToArray() }; list.Add(item); } } return(new GrantsViewModel { Grants = list }); }
private async Task <GrantsViewModel> BuildViewModelAsync() { var userGrants = await _interactionService.GetAllUserGrantsAsync(); var grants = new List <GrantViewModel>(); foreach (var grant in userGrants) { var client = await _clientStore.FindClientByIdAsync(grant.ClientId); if (client == null) { continue; } var resources = await _resourceStore.FindResourcesByScopeAsync(grant.Scopes); var item = new GrantViewModel { ClientId = client.ClientId, ClientName = client.ClientName ?? client.ClientId, ClientLogoUrl = client.LogoUri, ClientUrl = client.ClientUri, Description = grant.Description, Created = grant.CreationTime, Expires = grant.Expiration, IdentityGrantNames = resources.IdentityResources.Select(resource => resource.DisplayName ?? resource.Name).ToArray(), ApiGrantNames = resources.ApiScopes.Select(scope => scope.DisplayName ?? scope.Name).ToArray() }; grants.Add(item); } return(new GrantsViewModel { Grants = grants }); }