public async Task AddScope(Scope scope) { using (var context = new PhotographContext()) { context.Scopes.Add(scope); await context.SaveChangesAsync(); } }
public async Task AddClient(Client client) { using (var context = new PhotographContext()) { client.ClientSecrets = client.ClientSecrets.Sha256(); context.Clients.Add(client); await context.SaveChangesAsync(); } }
public async Task DeleteScope(int id) { using (var context = new PhotographContext()) { var scope = await context.Scopes.FirstOrDefaultAsync(x => x.Id.Equals(id)); context.Scopes.Remove(scope); await context.SaveChangesAsync(); } }
public async Task DeleteClient(int id) { using (var context = new PhotographContext()) { var client = await context.Clients.FirstOrDefaultAsync(x => x.Id.Equals(id)); context.Clients.Remove(client); await context.SaveChangesAsync(); } }
public async Task UpdateScope(Scope scope) { using (var context = new PhotographContext()) { var dbScope = await context.Scopes.FirstOrDefaultAsync(x => x.Id.Equals(scope.Id)); if (dbScope != null) { dbScope.IncludeAllClaimsForUser = scope.IncludeAllClaimsForUser; dbScope.Name = scope.Name; } await context.SaveChangesAsync(); } }