private string GetSettingNameDefaultValue(SettingNames settingName) { MemberInfo enumValue = typeof(SettingNames).GetMember(settingName.ToString())[0]; DefaultValueAttribute defaultValue = (DefaultValueAttribute)enumValue.GetCustomAttributes(typeof(DefaultValueAttribute), false).FirstOrDefault(); if (defaultValue != null) { return(defaultValue.Value.ToString()); } return(null); }
private void SaveSetting(SettingNames settingName, string value) { int settingId = (int)settingName; Setting setting = database.Settings.Find(settingId); if (setting == null) { setting = new Setting { Id = settingId, Description = settingName.ToString() }; database.Settings.Add(setting); } setting.Value = value; database.SaveChanges(); }