public bool DeleteSetting(Setting setting) { if (setting == null) return false; _unitOfWork.SettingRepository.Delete(setting); _unitOfWork.Save(); return true; }
public void EditSetting(Setting s) { ////Setting set = context.Settings.FirstOrDefault(m => m.Key == s.Key); ////if (set != null) ////{ //// set.Category = s.Category; //// set.Value = s.Value; //// set.Option = s.Option; //// set.Type = s.Type; //// context.SaveChanges(); ////} ////else ////{ //// context.Settings.Add(s); //// context.SaveChanges(); ////} //else //{ // set = new Setting(); // set.Category = s.Category; // set.Key = s.Key; // set.Value = s.Value; // set.Option = s.Option; // set.Type = s.Type; // context.Settings.AddObject(set); //} }
public ActionResult EditConfigSMTP(SMTPInfo smtp_info) { // If the ModelState is invalid then return // a PartialView passing in the Profile object // with the ModelState errors if (!ModelState.IsValid) return PartialView("SysSettings", smtp_info); // Store the Profile object and return // a Json result indicating the Profile // has been saved Session["SMTPInfo"] = smtp_info; //context.Connection.Open(); Setting setting = new Setting(); if (_settingService.FindBy(m => m.Key == "SMTPServer").FirstOrDefault() != null) { setting.Key = "SMTPServer"; setting.Value = smtp_info.SMTPServer; setting.Type = "String"; setting.Option = ""; setting.Category = "SMTP Config"; syssetting.EditSetting(setting); setting.Key = "SMTPPort"; setting.Value = smtp_info.Port.ToString(); setting.Type = "Int"; syssetting.EditSetting(setting); setting.Key = "SMTPName"; setting.Value = smtp_info.Name; setting.Type = "String"; syssetting.EditSetting(setting); } else { setting.Key = "SMTPServer"; setting.Value = smtp_info.SMTPServer; setting.Type = "String"; setting.Option = ""; setting.Category = "SMTP Config"; syssetting.AddSetting(setting); setting.Key = "SMTPPort"; setting.Value = smtp_info.Port.ToString(); setting.Type = "Int"; syssetting.AddSetting(setting); setting.Key = "SMTPName"; setting.Value = smtp_info.Name; setting.Type = "String"; syssetting.AddSetting(setting); } //if (context.MailServerSettings.Count() == 0) //{ // MailServerSetting m = new MailServerSetting(); // m.Name = smtp_info.Name; // m.Port = smtp_info.Port; // m.SMTPServer = smtp_info.SMTPServer; // context.MailServerSettings.AddObject(m); //} //else //{ // MailServerSetting m = context.MailServerSettings.First(); // m.Name = smtp_info.Name; // m.Port = smtp_info.Port; // m.SMTPServer = smtp_info.SMTPServer; //} //context.SaveChanges(); return Json(new { success = true }); }
public ActionResult SysSettingsUpdate() { SMTPInfo smtp_info = new SMTPInfo(); // Retrieve the perviously saved Profile if (Session["SMTPInfo"] != null) smtp_info = Session["SMTPInfo"] as SMTPInfo; //CTSContext context = new CTSContext(); Setting setting = new Setting(); setting = syssetting.GetSetting("SMTPServer"); if (setting != null) smtp_info.SMTPServer = setting.Value; setting = syssetting.GetSetting("SMTPPort"); if (setting != null) smtp_info.Port = int.Parse(setting.Value); setting = syssetting.GetSetting("SMTPName"); if (setting != null) smtp_info.Name = setting.Value; Session["SMTPInfo"] = smtp_info; this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); this.Response.Cache.SetCacheability(HttpCacheability.NoCache); this.Response.Cache.SetNoStore(); return PartialView(smtp_info); }
public bool EditSetting(Setting setting) { _unitOfWork.SettingRepository.Edit(setting); _unitOfWork.Save(); return true; }
public bool AddSetting(Setting setting) { _unitOfWork.SettingRepository.Add(setting); _unitOfWork.Save(); return true; }
public void AddSetting(Setting s) { ////context.Settings.Add(s); ////context.SaveChanges(); }