public async Task CreateIdentityResource(string siteId, IdentityResource identityResource, CancellationToken cancellationToken = default(CancellationToken)) { var ent = identityResource.ToEntity(); ent.SiteId = siteId; using (var context = _contextFactory.CreateContext()) { context.IdentityResources.Add(ent); await context.SaveChangesAsync(); } }
public async Task CreateClient(string siteId, Client client, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var ent = client.ToEntity(); ent.SiteId = siteId; using (var context = _contextFactory.CreateContext()) { context.Clients.Add(ent); await context.SaveChangesAsync().ConfigureAwait(false); } }
public async Task <IdentityResource> FetchIdentityResource(string siteId, string name, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); using (var context = _contextFactory.CreateContext()) { IQueryable <Entities.IdentityResource> query = context.IdentityResources .AsNoTracking() .Include(x => x.UserClaims); query = query.Where(x => x.SiteId == siteId && x.Name == name); var ent = await query.SingleOrDefaultAsync(); return(ent.ToModel()); } }
public async Task CreateApiResource(string siteId, ApiResource apiResource, CancellationToken cancellationToken = default(CancellationToken)) { var ent = apiResource.ToEntity(); ent.SiteId = siteId; foreach (var s in ent.Scopes) { s.SiteId = siteId; } using (var context = _contextFactory.CreateContext()) { context.ApiResources.Add(ent); await context.SaveChangesAsync(); } }
public async Task <Client> FetchClient(string siteId, string clientId, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); using (var context = _contextFactory.CreateContext()) { var client = await context.Clients .AsNoTracking() .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.Properties) .Include(x => x.AllowedCorsOrigins) .FirstOrDefaultAsync(x => x.SiteId == siteId && x.ClientId == clientId); var model = client.ToModel(); return(model); } }