public ActionResult Edit(int id = 0, string redirectUrl = "") { PostModel model = null; using (Contexts.PostContext context = new Contexts.PostContext()) { model = context.GetPost(id); ViewBag.PostPriceTypes = context.GetPostPriceTypes(true); } return View(model); }
public ActionResult Edit(PostModel model, string redirectUrl = "") { if (!ModelState.IsValid) { using (Contexts.PostContext context = new Contexts.PostContext()) { ViewBag.PostPriceTypes = context.GetPostPriceTypes(true); } return View("Edit", model); } else { using (Contexts.PostContext context = new Contexts.PostContext()) { context.Edit(model); } return Redirect(redirectUrl); } }