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))); }
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); } }
public static int GetSinglePrice(this GymContextDataContext db) { return(db.Get <int>("single_price")); }
public static int GetInsurancePrice(this GymContextDataContext db) { return(db.Get <int>("insurance_price")); }