public ActionResult Edit(EditPostModel post) { if (String.IsNullOrEmpty(post.Title)) ModelState.AddModelError("Title", "Title is required"); if (ModelState.IsValid) { _model.UpdatePost(Mapper.Map<EditPostModel, Post>(post)); return RedirectToAction("Edit", new { PostID = post.Id }); } return View(post); }
public ActionResult Edit(Post post) { if (String.IsNullOrEmpty(post.Title)) ModelState.AddModelError("Title", "Title is required"); if (ModelState.IsValid) { _model.UpdatePost(post); return RedirectToAction("Edit", new { PostID = post.Id }); } var viewModel = new EditPostModel() { Post = post }; return View(viewModel); }
public ActionResult Edit(int PostID) { var viewModel = new EditPostModel(); viewModel.Post =_model.GetPost(PostID); return View(viewModel); }