Beispiel #1
0
        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();
        }
Beispiel #2
0
        public async Task <Models.Consent> LoadAsync(string subject, string client)
        {
            var found = await context.Consents
                        .Where(x => x.SubjectId == subject && x.ClientId == client)
                        .FirstOrDefaultAsync();

            if (found == null)
            {
                return(null);
            }

            var result = new Models.Consent
            {
                Subject  = found.SubjectId,
                ClientId = found.ClientId,
                Scopes   = found.Scopes.ParseScopes()
            };

            return(result);
        }