public ActionResult EditBook(int id) { var book = _bookService.GetBookById(id); var bookModel = new SetBookModel() { Id = book.Id, Isbn = book.Isbn, Name = book.Name, DegreeId = book.DegreeId, GradeId = book.GradeId, SubjectId = book.SubjectId, Year = book.Year, PublisherId = book.PublisherId, TermId = book.TermId }; PrepareBookModel(bookModel); return(View(bookModel)); }
public ActionResult EditBook(SetBookModel model) { if (!ModelState.IsValid) { PrepareBookModel(model); return(View(model)); } var book = _bookService.GetBookById(model.Id); book.SubjectId = model.SubjectId; book.DegreeId = model.DegreeId; book.GradeId = model.GradeId; book.TermId = model.TermId; book.Year = model.Year; book.Isbn = model.Isbn; book.Name = model.Name; book.PublisherId = model.PublisherId; book.SubjectId = model.SubjectId; book.Version = model.Version; _bookService.UpdateBook(book); return(RedirectToAction("Index")); }