public async Task <IActionResult> Edit(int id, [Bind("BookID,Title,PubDate,Category,AuthorID")] Book book) { if (id != book.BookID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(book); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.BookID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AuthorID"] = new SelectList(_context.Set <Author>(), "AuthorID", "LastName", book.AuthorID); return(View(book)); }
public async Task <IActionResult> Edit(int id, [Bind("bookId,title,author,isbn,publisher,year")] Book book) { if (id != book.bookId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(book); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.bookId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(book)); }
public bool UpdateBook(List <int> authorId, List <int> categorieId, Book book) { var authors = _bookDBContext.Authors.Where(a => authorId.Contains(a.Id)).ToList(); var categories = _bookDBContext.Categories.Where(c => categorieId.Contains(c.Id)).ToList(); var bookauthortodelete = _bookDBContext.BookAuthors.Where(b => b.BookId == book.Id); var bookcategorytodelete = _bookDBContext.BookCategories.Where(c => c.BookId == book.Id); _bookDBContext.RemoveRange(bookauthortodelete); _bookDBContext.RemoveRange(bookcategorytodelete); foreach (var a in authors) { var bookauthor = new BookAuthor { Author = a, Book = book }; } foreach (var c in categories) { var bookcategories = new BookCategory { Category = c, Book = book }; } _bookDBContext.Update(book); return(Save()); }
public bool UpdateCountry(Country country) { _bookDBContext.Update(country); return(Save()); }
public bool UpdateCategory(Category category) { _bookDBContext.Update(category); return(Save()); }
public bool UpdateAuthor(Author author) { _bookDBContext.Update(author); return(Save()); }
public bool UpdateReview(Review review) { _reviewRepository.Update(review); return(Save()); }