public ScopeStore(ScopeConfigurationDbContext context) { if (context == null) { throw new ArgumentNullException("context"); } this.context = context; }
public static void ConfigureScopes(IEnumerable<Scope> scopes, EntityFrameworkServiceOptions options) { using (var db = new ScopeConfigurationDbContext(options.ConnectionString, options.Schema)) { if (!db.Scopes.Any()) { foreach (var s in scopes) { var e = s.ToEntity(); db.Scopes.Add(e); } db.SaveChanges(); } } }
protected override void ProcessRecord() { //var db = new ClientConfigurationDbContext(this.ConnectionString, this.Schema); var db = new ScopeConfigurationDbContext(this.ConnectionString, this.Schema); if (!string.IsNullOrEmpty(ScopeName)) { var scope = db.Scopes.FirstOrDefault(s => s.Name == ScopeName); WriteObject(scope.ToModel()); } else { var dbscopes = db.Scopes.ToList(); var scopes = from c in dbscopes select c.ToModel(); WriteObject(scopes); } }
protected override void ProcessRecord() { var db = new ScopeConfigurationDbContext(this.ConnectionString, this.Schema); var scope = new Thinktecture.IdentityServer.Core.Models.Scope { Name = this.Name, DisplayName = this.DisplayName, Description = this.Description, Type = this.ScopeType, ShowInDiscoveryDocument = this.Discoverable, Emphasize = this.Emphasize, Required = this.Required, }; db.Scopes.Add(scope.ToEntity()); db.SaveChanges(); WriteObject(scope); }
protected override void ProcessRecord() { var db = new ScopeConfigurationDbContext(this.ConnectionString, this.Schema); var entity = db.Scopes.Single(c => c.Name == this.Scope.Name); var currentId = entity.Id; var currentscope = entity.ToModel(); var attachedEntry = db.Entry(entity); var newentity = this.Scope.ToEntity(); newentity.Id = currentId; attachedEntry.CurrentValues.SetValues(newentity); // Synchronize scope claims nav property - FIXME ugly foreach (var scope in currentscope.Claims.Union(this.Scope.Claims).Distinct()) { if (currentscope.Claims.Any(x => x.Name == scope.Name) && !this.Scope.Claims.Any(x => x.Name == scope.Name)) entity.ScopeClaims.Remove(entity.ScopeClaims.First(x => x.Name == scope.Name)); else if (!currentscope.Claims.Any(x => x.Name == scope.Name) && this.Scope.Claims.Any(x => x.Name == scope.Name)) entity.ScopeClaims.Add(new Thinktecture.IdentityServer.EntityFramework.Entities.ScopeClaim() { Name = scope.Name, Description = scope.Description, AlwaysIncludeInIdToken = scope.AlwaysIncludeInIdToken }); } db.SaveChanges(); }
protected override void ProcessRecord() { var db = new ScopeConfigurationDbContext(this.ConnectionString, this.Schema); var entity = db.Scopes.First(s => s.Name == this.ScopeName); db.Scopes.Remove(entity); db.SaveChanges(); }
public ScopeStore(ScopeConfigurationDbContext context) { if (context == null) throw new ArgumentNullException("context"); this.context = context; }