public SettingConfigManager()
 {
     defaultModel = new SettingsViewModels
     {
         DeadLine = DateTime.Now,
         PageCount = 5
     };
 }
 public bool SetConfigs(SettingsViewModels settings, out string ErrorMsg)
 {
     ErrorMsg = null;
     try
     {
         using(var ctx = new EvaluationSysEntities())
         {
             var query = (from c in ctx.SettingConfig where c.ConfigStatus >= 0 select c).ToList();
             foreach(PropertyInfo p in typeof(SettingsViewModels).GetProperties())
             {
                 var setting = query.FirstOrDefault(f => f.Name == p.Name);
                 if(setting == null)
                 {
                     ctx.SettingConfig.Add(new SettingConfig
                     {
                         Id = Guid.NewGuid(),
                         ConfigStatus = 1,
                         CreateTime = DateTime.Now,
                         Name = p.Name,
                         Value = Convert.ToString(p.GetValue(settings)),
                         OperateTime = DateTime.Now
                     });
                 }
                 else
                 {
                     setting.Value = Convert.ToString(p.GetValue(settings));
                     setting.OperateTime = DateTime.Now;
                 }
             }
             return ctx.SaveChanges() >= 0;
         }
     }
     catch(Exception ex)
     {
         ErrorMsg = ex.GetBaseException().Message;
         return false;
     }
 }
 public ActionResult OtherSettingsSave(SettingsViewModels setting)
 {
     string err = null;
     if (configManager.SetConfigs(setting, out err))
     {
         return Json(new { IsErr = false });
     }
     else return Json(new { IsErr = true, ErrMsg = HttpUtility.JavaScriptStringEncode(err) });
 }