public async Task <IActionResult> Edit(int id, [Bind("BookId,ISBN,Title,AuthorId,PublisherId")] 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.Author, "AuthorId", "Name", book.AuthorId); ViewData["PublisherId"] = new SelectList(_context.Set <Publisher>(), "PublisherId", "Name", book.PublisherId); return(View(book)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,FirstName,LastName,PhoneNumber,Email,Address")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("PublisherId,Name")] Publisher publisher) { if (id != publisher.PublisherId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(publisher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublisherExists(publisher.PublisherId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(publisher)); }
public async Task <IActionResult> Edit(int id, [Bind("RentalId,RentalDate,ReturnDate,BookId,UserId")] Rental rental) { if (id != rental.RentalId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rental); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RentalExists(rental.RentalId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BookId"] = new SelectList(_context.Book, "BookId", "Title", rental.BookId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "Name", rental.UserId); return(View(rental)); }
public async Task <IActionResult> Edit(int id, [Bind("Periodicity,Number,Id,Title,Quantity,Year,Edition")] Magazine magazine) { if (id != magazine.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(magazine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MagazineExists(magazine.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(magazine)); }
public async Task <IActionResult> Edit(int id, [Bind("Author,Genre,Id,Title,Quantity,Year,Edition")] Book book) { if (id != book.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(book); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(book.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(book)); }
public void Update(Librarian entity) { var response = librarianContext.Update(entity); librarianContext.SaveChanges(); }