public ActionResult Create(Book book) { if (ModelState.IsValid) { try { UpdateModel(book); _repository.Update(book); _repository.Commit(); return RedirectToAction("Details", new {id = book.Isbn}); } catch { var errors = book.GetErrorMessages(); foreach (var error in errors) { ModelState.AddModelError(error.Property, error.ErrorMessage); } } } return View(book); }
public void Update(Book book) { if (book == null) throw new ArgumentNullException("book"); _session.SaveOrUpdate(book); }
public ActionResult Create() { var book = new Book(); return View(book); }