public async Task <Client> GetClient(String clientId, CancellationToken cancellationToken) { Client clientModel = null; Duende.IdentityServer.EntityFramework.Entities.Client clientEntity = await this.ConfigurationDbContext .Clients.Include(c => c.AllowedGrantTypes).Include(c => c.AllowedScopes) .Where(c => c.ClientId == clientId) .SingleOrDefaultAsync(cancellationToken: cancellationToken); if (clientEntity == null) { throw new NotFoundException($"No client found with Client Id [{clientId}]"); } clientModel = clientEntity.ToModel(); return(clientModel); }
/// <summary> /// Maps an entity to a model. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static Models.Client ToModel(this Duende.IdentityServer.EntityFramework.Entities.Client entity) { return(Mapper.Map <Models.Client>(entity)); }