Example #1
0
        public SettingsDatabase(SettingsDbContext context)
        {
            this.context = context;

#if DEBUG
            context.Database.Log = Log.Logger;
#endif
        }
Example #2
0
        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);
            }
        }
Example #4
0
        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);
            }
        }
Example #6
0
        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();
 }
Example #8
0
 public ValidationRepository()
 {
     _context = new SettingsDbContext();
 }