public ActionResult CreateSection(ChangeSectionModel model) { if (ModelState.IsValid) { var result = repository.AddSection(new Section { SectionTitle = model.SectionTitle }); if (!result) { TempData["failure"] = "Раздел не был добавлен."; } else { TempData["success"] = "Раздел был добавлен."; } } else { TempData["failure"] = "Раздел не был добавлен."; } ModelState.Clear(); return RedirectToAction("GetSections"); }
public ActionResult _SubmitSectionChange(ChangeSectionModel section) { using (var context = new SimpleMembershipContext()) { var db_section = context.Sections.FirstOrDefault(x => x.SectionId == section.SectionId); if (ModelState.IsValid) { try { db_section.SectionTitle = section.SectionTitle; context.SaveChanges(); } catch { Response.StatusCode = (int)HttpStatusCode.BadRequest; } } else { section.SectionTitle = db_section.SectionTitle; Response.StatusCode = (int)HttpStatusCode.BadRequest; } } return PartialView("_Section", section); }
public ActionResult _HideRenameForm(ChangeSectionModel section) { return PartialView("_Section", section); }
public ActionResult _RenameSection(ChangeSectionModel section) { return PartialView(section); }
public ActionResult RemoveSection(ChangeSectionModel section) { if (ModelState.IsValid) { var result = repository.RemoveSection(section.SectionId); if (result) { section = null; } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; } } else { Response.StatusCode = (int)HttpStatusCode.BadRequest; } return PartialView("_Section", section); }