public void setString(string key, string value) { C_Property property = db.C_Properties.Find(key); if (property == null) { property = new C_Property { Key = key, Type = PropertyTypes.STRING, Value = value }; db.C_Properties.Add(property); } else { if (isString(property)) { property.Value = value; } } db.SaveChanges(); }
public void setBool(string key, bool value) { C_Property property = db.C_Properties.Find(key); if(property == null) { property = new C_Property { Key = key, Type = PropertyTypes.BOOL, Value = value.ToString() }; db.C_Properties.Add(property); } else { if (isBool(property)) { property.Value = value.ToString(); } } db.SaveChanges(); }
public void setInt(string key, int value) { C_Property property = db.C_Properties.Find(key); if (property == null) { property = new C_Property { Key = key, Type = PropertyTypes.INT, Value = value.ToString() }; db.C_Properties.Add(property); } else { if (isInt(property)) { property.Value = value.ToString(); ; } } db.SaveChanges(); }
private bool isInt(C_Property property) { if (property.Type == PropertyTypes.INT) { return true; } else { throw new Exception("Property " + property.Key + " is not a integer"); } }
private bool isString(C_Property property) { if (property.Type == PropertyTypes.STRING) { return true; } else { throw new Exception("Property " + property.Key + " is not a string"); } }
private bool isBool(C_Property property) { if (property.Type == PropertyTypes.BOOL) { return true; } else { throw new Exception("Property " + property.Key + " is not a boolean"); } }