public void SaveSetting(Setting Setting) { if (Setting.Id == 0) { _RSetting.Add(Setting); } else { _uow.Entry(Setting).State = EntityState.Modified; } _uow.SaveChanges(); }
public ActionResult SaveSetting(string ckEditor, Introductiontype type) { var setting = _rSettingRepository.Settings.FirstOrDefault(_ => _.LanguageId == _LanguageId); if(setting == null) { var obj = new Setting() { LanguageId = _LanguageId, Certificates = " ", CompanyHistory = " ", MissionStatement = " ", //Perspective = " ", //Provisions = " ", Awards = " " , AboutUs = " ", CompanyIntroduce = " ", ContactUs = " " }; _rSettingRepository.SaveSetting(obj); setting = obj; } if(IsValidSessions()) { switch (type) { case Introductiontype.CompanyHistory: setting.CompanyHistory = ckEditor; _rSettingRepository.SaveSetting(setting); TempData["result"] = "OK"; TempData["Message"] = "عملیات با موفقیت انجام شد."; return PartialView("_SuccWrittenBy"); case Introductiontype.MissionStatement: setting.MissionStatement = ckEditor; _rSettingRepository.SaveSetting(setting); TempData["result"] = "OK"; TempData["Message"] = "عملیات با موفقیت انجام شد."; return PartialView("_SuccWrittenBy"); case Introductiontype.Certificates: setting.Certificates = ckEditor; _rSettingRepository.SaveSetting(setting); TempData["result"] = "OK"; TempData["Message"] = "عملیات با موفقیت انجام شد."; return PartialView("_SuccWrittenBy"); case Introductiontype.Awards: setting.Awards = ckEditor; _rSettingRepository.SaveSetting(setting); TempData["result"] = "OK"; TempData["Message"] = "عملیات با موفقیت انجام شد."; return PartialView("_SuccWrittenBy"); case Introductiontype.Specifications: setting.RajiGazSpecifications = ckEditor; _rSettingRepository.SaveSetting(setting); TempData["result"] = "OK"; TempData["Message"] = "عملیات با موفقیت انجام شد."; return PartialView("_SuccWrittenBy"); } return Json(new { result = "false" }); } else return RedirectToAction("login", "Home"); }