public ActionResult Edit(string isbn, FormCollection collection) { if (Session["User"] == null) { return(RedirectToAction("Login", "Pages")); } try { ViewBag.authors = Author.getAll(); ViewBag.AuthorId = BookAuthor.getAuthorId(isbn); } catch { return(View("Error500")); } try { // Let's create a new book and fill it with the form's data BL.Book book = BL.Book.getByISBN(isbn); book.Title = collection["Title"] as string; book.Pages = Convert.ToInt32(collection["Pages"]); book.SignId = Convert.ToInt32(collection["SignId"]); book.PublicationInfo = collection["PublicationInfo"] as string; book.PublicationYear = collection["PublicationYear"] as string; book.edit(); // Let's also update the link between the book and its author BL.BookAuthor.edit(book.ISBN, Convert.ToInt32(collection["AuthorId"])); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(string isbn) { if (Session["User"] == null) { return(RedirectToAction("Login", "Pages")); } Book book; try { book = BL.Book.getByISBN(isbn); ViewBag.authors = Author.getAll(); ViewBag.AuthorId = BookAuthor.getAuthorId(isbn); } catch { return(View("Error500")); } return(View(book)); }