public async Task <bool> UpdateAsync(Core.Models.Client client) { using (var transaction = await _context.Database.BeginTransactionAsync().ConfigureAwait(false)) { try { var record = client.ToEntity(); var result = await _context.Clients.FirstOrDefaultAsync(c => c.ClientId == record.ClientId).ConfigureAwait(false); if (result == null) { return(false); } result.ClientName = record.ClientName; result.Enabled = record.Enabled; result.RequireClientSecret = record.RequireClientSecret; result.RequireConsent = record.RequireConsent; result.AllowRememberConsent = record.AllowRememberConsent; result.LogoutSessionRequired = record.LogoutSessionRequired; result.IdentityTokenLifetime = record.IdentityTokenLifetime; result.AccessTokenLifetime = record.AccessTokenLifetime; result.AuthorizationCodeLifetime = record.AuthorizationCodeLifetime; result.AbsoluteRefreshTokenLifetime = record.AbsoluteRefreshTokenLifetime; result.SlidingRefreshTokenLifetime = record.SlidingRefreshTokenLifetime; result.RefreshTokenUsage = record.RefreshTokenUsage; result.RefreshTokenExpiration = record.RefreshTokenExpiration; result.EnableLocalLogin = record.EnableLocalLogin; result.PrefixClientClaims = record.PrefixClientClaims; result.LogoUri = record.LogoUri; result.ClientUri = record.ClientUri; result.AllowedScopes = record.AllowedScopes; result.RedirectUris = record.RedirectUris; result.AllowedGrantTypes = record.AllowedGrantTypes; await _context.SaveChangesAsync().ConfigureAwait(false);; transaction.Commit(); return(true); } catch (Exception ex) { _managerEventSource.Failure(ex); transaction.Rollback(); return(false); } } }
public async Task <bool> InsertAsync(Core.Models.Client client) { using (var transaction = await _context.Database.BeginTransactionAsync().ConfigureAwait(false)) { try { var record = client.ToEntity(); _context.Clients.Add(record); await _context.SaveChangesAsync().ConfigureAwait(false);; transaction.Commit(); return(true); } catch (Exception ex) { _managerEventSource.Failure(ex); transaction.Rollback(); return(false); } } }