Ejemplo n.º 1
0
        public async Task UpdateAsync(IdentityServer3.Core.Models.Consent consent)
        {
            Consent item = null;

            if (options != null && options.SynchronousReads)
            {
                item = context.Consents.Find(consent.Subject, consent.ClientId);
            }
            else
            {
                item = await context.Consents.FindAsync(consent.Subject, consent.ClientId);
            }

            if (item == null)
            {
                item = new Entities.Consent
                {
                    Subject  = consent.Subject,
                    ClientId = consent.ClientId
                };
                context.Consents.Add(item);
            }

            if (consent.Scopes == null || !consent.Scopes.Any())
            {
                context.Consents.Remove(item);
            }

            item.Scopes = StringifyScopes(consent.Scopes);

            await context.SaveChangesAsync();
        }
        public async Task UpdateAsync(IdentityServer3.Core.Models.Consent consent)
        {
            var item = await context.Consents.FindAsync(consent.Subject, consent.ClientId);
            if (item == null)
            {
                item = new Entities.Consent 
                { 
                    Subject = consent.Subject, 
                    ClientId = consent.ClientId 
                };
                context.Consents.Add(item);
            }
                
            if (consent.Scopes == null || !consent.Scopes.Any())
            {
                context.Consents.Remove(item);
            }

            item.Scopes = StringifyScopes(consent.Scopes);

            await context.SaveChangesAsync();
        }