public async Task <IActionResult> EditBook(int id, Book book) { if (id != book.Id) { return(BadRequest()); } var bookUpdate = await BookService.FindBookById(id); bookUpdate.Isbn = book.Isbn; bookUpdate.Title = book.Title; bookUpdate.Year = book.Year; try { await BookService.UpdateBook(bookUpdate); } catch (DbUpdateConcurrencyException) { if (!BookService.BookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult Edit(int id, [Bind("ID,Title,Price,Status,Type,Author")] Book book) { if (id != book.ID) { return(NotFound()); } if (ModelState.IsValid) { try { //repo.Book.Update(book); //repo.Save(); bookService.UpdateBook(book); } catch (DbUpdateConcurrencyException) { if (!bookService.BookExists(book.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(book)); }
// GET: Book public ActionResult GetBook(string isbn) { if (!BookService.BookExists(isbn)) { return(Redirect("/Error/Code/404")); } return(View(BookService.GetBookWithAuthors(isbn))); }
public ActionResult Book(string id) { if (new Auth((BorrowerWithUser)Session["User"]).HasAdminPermission()) { if (!BookService.BookExists(id)) { return(Redirect("/Error/Code/404")); } return(View(BookService.GetBookWithAuthorsAndAuthors(id))); } return(Redirect("/Error/Code/403")); }