public ActionResult Edit(PageContentViewModel form) { if (!ModelState.IsValid) { return View(form); } var pageContent = _context.PageContents.SingleOrDefault(i => i.Id == form.Id); if (pageContent == null) { return RedirectToAction("Index"); //return RedirectToAction<ManagePageContentsController>(c => c.Index()) // .WithError("Unable to find the page. Maybe it was deleted?"); } pageContent.PageCode = form.PageCode; pageContent.Content = HttpUtility.HtmlDecode(form.Content); _context.Entry(pageContent).State = EntityState.Modified; _context.SaveChanges(); return RedirectToAction("Index"); //return RedirectToAction<ManagePageContentsController>(c => c.Index()).WithSuccess("Changes saved!"); }
public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var pageContent = _context.PageContents.Find(id); if (pageContent == null) { return HttpNotFound(); } var model = new PageContentViewModel { PageCode = pageContent.PageCode, Content = HttpUtility.HtmlDecode(pageContent.Content) }; return View(model); }