public ActionResult Rules() { var ecId = WebUserInfo.SiteId; var educationalCenter = _db.Set <EducationalCenter>().Include(ec => ec.Site).First(ec => ec.Id == ecId); var ruleViewModel = new EducationalCenterRuleDto { Rule = educationalCenter.Rule, EducationalCenterName = $"قوانین مرکز آموزشی {educationalCenter.Site.Name}" }; return(View(ruleViewModel)); }
public ActionResult Rules(EducationalCenterRuleDto model) { var clearerRule = model.Rule.Replace(" ", "").Replace("<p>", "").Replace("<br>", "").Replace("</p>", ""); if (clearerRule.IsNullOrWhiteSpace()) { return(Json(new { success = false, message = "قوانین مرکز آموزشی را وارد نمایید" }, JsonRequestBehavior.AllowGet)); } var ecId = WebUserInfo.SiteId; var educationalCenter = _db.Set <EducationalCenter>().First(ec => ec.Id == ecId); educationalCenter.Rule = model.Rule; _db.Entry(educationalCenter).State = EntityState.Modified; _db.SaveChanges(); return(Json(new { success = true, message = "قوانین مرکز آموزشی ذخیره شد" }, JsonRequestBehavior.AllowGet)); }