public async Task UpdateAsync(Models.Consent consent) { var item = await context.Consents .Where(x => x.SubjectId == consent.Subject && x.ClientId == consent.ClientId) .FirstOrDefaultAsync(); if (item == null) { item = new Entities.Consent { SubjectId = consent.Subject, ClientId = consent.ClientId }; context.Consents.Add(item); } if (consent.Scopes == null || !consent.Scopes.Any()) { context.Consents.Remove(item); } item.Scopes = consent.Scopes.StringifyScopes(); await context.SaveChangesAsync(); }
public async Task StoreUserConsentAsync(Consent consent) { var item = await _context.Consents .Where(x => x.SubjectId == consent.SubjectId && x.ClientId == consent.ClientId) .FirstOrDefaultAsync(); if (item == null) { item = new Entities.Consent { SubjectId = consent.SubjectId, ClientId = consent.ClientId }; _context.Consents.Add(item); } if (consent.Scopes == null || !consent.Scopes.Any()) { _context.Consents.Remove(item); } item.Scopes = consent.Scopes.StringifyScopes(); await((DbContext)_context).SaveChangesAsync(); }