public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { string clientId = string.Empty; string clientSecret = string.Empty; string symmetricKeyAsBase64 = string.Empty; if (!context.TryGetBasicCredentials(out clientId, out clientSecret)) { context.TryGetFormCredentials(out clientId, out clientSecret); } if (context.ClientId == null) { context.SetError("invalid_clientId", "client_Id is not set"); return(Task.FromResult <object>(null)); } Models.Audience audience = AudiencesStore.FindAudience(context.ClientId); if (audience == null) { context.SetError("invalid_clientId", string.Format("Invalid client_id '{0}'", context.ClientId)); return(Task.FromResult <object>(null)); } context.Validated(); return(Task.FromResult <object>(null)); }
public static int Save(Models.Audience audience) { using (var db = new Context.SqlContext()) { db.Entry(audience).State = audience.AudienceId.Equals(0) ? EntityState.Added : EntityState.Modified; var ret = db.SaveChanges(); return(ret); } }
public static object Delete(Models.Audience audience) { using (var db = new Context.SqlContext()) { db.Entry(audience).State = audience.AudienceId.Equals(0) ? EntityState.Unchanged : EntityState.Deleted; var ret = db.SaveChanges(); return(ret); } }
/// <inheritdoc /> public async Task <Audience> GetByFeatureId(Guid featureId, CancellationToken cancellationToken = default) { if (featureId == Guid.Empty) { throw new ArgumentException("Invalid Feature Id"); } Models.Audience audience = await _dbContext.Audiences .SingleOrDefaultAsync(a => a.FeatureId == featureId, cancellationToken) .ConfigureAwait(false); return(audience == null ? null : _iMapper.Map <Models.Audience, Audience>(audience)); }
public static Models.Audience GetSchoolAudience(string school, bool createIfMissing) { using (var db = new Context.SqlContext()) { if (string.IsNullOrEmpty(school)) { return(null); } var n = db.Audience.FirstOrDefault <Models.Audience>(v => v.SchoolAudienceValue.Equals(school) & v.GradeLevelAudienceValue.Equals(null) & v.TeacherAudienceValue.Equals(null)); if ((n == null) && (createIfMissing)) { n = new Models.Audience(); n.SchoolAudienceValue = school; n.AudienceName = school; n.Selectable = true; Save(n); } return(n); } }