示例#1
0
 public async Task AddScope(Scope scope)
 {
     using (var context = new PhotographContext())
     {
         context.Scopes.Add(scope);
         await context.SaveChangesAsync();
     }
 }
示例#2
0
 public async Task AddClient(Client client)
 {
     using (var context = new PhotographContext())
     {
         client.ClientSecrets = client.ClientSecrets.Sha256();
         context.Clients.Add(client);
         await context.SaveChangesAsync();
     }
 }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        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();
            }
        }