public SettingsDatabase(SettingsDbContext context) { this.context = context; #if DEBUG context.Database.Log = Log.Logger; #endif }
public void SetUsed(string apiKey) { try { using (var context = new SettingsDbContext()) { var data = context.ApiKeys.SingleOrDefault(a => a.ApiKey == apiKey); if (data != null) { data.LastUsed = DateTime.UtcNow; context.SaveChanges(); } } } catch (Exception ex) { Log.Exception(ex); throw new SettingsStoreException(Constants.ERROR_STORE_UNAVAILABLE, ex); } }
public bool IsValid(string key, out int keyId) { keyId = 0; try { using (var context = new SettingsDbContext()) { ApiKeyData data = context.ApiKeys.SingleOrDefault(a => a.ApiKey == key); if (data != null) { keyId = data.Id; return data.Active; } return false; } } catch (Exception ex) { Log.Exception(ex); throw new SettingsStoreException(Constants.ERROR_STORE_UNAVAILABLE, ex); } }
public bool IsValid(string key, out int keyId) { keyId = 0; try { using (var context = new SettingsDbContext()) { ApiKeyData data = context.ApiKeys.SingleOrDefault(a => a.ApiKey == key); if (data != null) { keyId = data.Id; return(data.Active); } return(false); } } catch (Exception ex) { Log.Exception(ex); throw new SettingsStoreException(Constants.ERROR_STORE_UNAVAILABLE, ex); } }
public ValidationRepository() { _context = new SettingsDbContext(); }