Exemplo n.º 1
0
        public static T Get <T>(this GymContextDataContext db, string key)
        {
            var value = db.Settings.Where(s => s.Key == key).FirstOrDefault()?.Value;

            if (value == null)
            {
                return(default(T));
            }
            return((T)Convert.ChangeType(value, typeof(T)));
        }
Exemplo n.º 2
0
 public static bool Set(this GymContextDataContext db, string key, string value)
 {
     try
     {
         var setting = db.Settings.Where(s => s.Key == key).FirstOrDefault();
         if (setting != null)
         {
             setting.Value = value;
         }
         else
         {
             setting = new Setting(); db.Settings.InsertOnSubmit(setting);
         }
         db.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public static int GetSinglePrice(this GymContextDataContext db)
 {
     return(db.Get <int>("single_price"));
 }
Exemplo n.º 4
0
 public static int GetInsurancePrice(this GymContextDataContext db)
 {
     return(db.Get <int>("insurance_price"));
 }