Exemplo n.º 1
0
 public async Task AddClient(Client client)
 {
     using (var context = new PhotographContext())
     {
         client.ClientSecrets = client.ClientSecrets.Sha256();
         context.Clients.Add(client);
         await context.SaveChangesAsync();
     }
 }
Exemplo n.º 2
0
        public async Task UpdateClient(Client client)
        {
            using (var context = new PhotographContext())
            {
                var dbClient = await context.Clients.FirstOrDefaultAsync(x => x.Id.Equals(client.Id));

                if (dbClient != null)
                {
                    dbClient.Flow                = client.Flow;
                    dbClient.Enabled             = client.Enabled;
                    dbClient.ClientSecrets       = client.ClientSecrets.Sha256();
                    dbClient.ClientName          = client.ClientName;
                    dbClient.AccessTokenLifetime = client.AccessTokenLifetime;
                    dbClient.ClientId            = client.ClientId;
                    dbClient.AllowedScopes.AddRange(client.AllowedScopes);
                }

                context.SaveChanges();
            }
        }