コード例 #1
0
 public void EnsureSchemaVersion()
 {
     try
     {
         var currentVersionSetting = AppSettings.CurrentSettings.SingleOrDefault(s => s.SettingName == "Version");
         if (currentVersionSetting == null)//if no version is set in DB yet, create initial version idicator first
         {
             currentVersionSetting = new Setting() { SettingName = "Version", SettingValue = "2.0.0", DefaultValue = "2.0.0", SettingDescription = "The version of the TicketDesk database. CHANGE AT YOUR OWN RISK!", SettingType = "SimpleString" };
             AppSettings.SaveSettings(new[] { currentVersionSetting });
         }
         UpgradeSchema("2.0.2");
     }
     catch { }
 }
コード例 #2
0
        public virtual ActionResult Edit(Setting setting)
        {
            try
            {
                var currentSetting = Settings.ApplicationSettings.CurrentSettings.SingleOrDefault(s => s.SettingName == setting.SettingName);
                TryUpdateModel(currentSetting, new[] { "SettingValue"});
                
                if (ModelState.IsValid)
                {
                    Settings.ApplicationSettings.SaveSettings(new[] { currentSetting });
                    // TODO: Add update logic here

                    return RedirectToAction(MVC.Admin.ApplicationSettings.List());
                }
                else
                {
                    return View(currentSetting);
                }
            }
            catch
            {
                return View();
            }
        }
コード例 #3
0
 /// <summary>
 /// Create a new Setting object.
 /// </summary>
 /// <param name="settingName">Initial value of the SettingName property.</param>
 /// <param name="settingType">Initial value of the SettingType property.</param>
 public static Setting CreateSetting(global::System.String settingName, global::System.String settingType)
 {
     Setting setting = new Setting();
     setting.SettingName = settingName;
     setting.SettingType = settingType;
     return setting;
 }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Settings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSettings(Setting setting)
 {
     base.AddObject("Settings", setting);
 }