public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Publisher publisher) { if (id != publisher.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(publisher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublisherExists(publisher.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(publisher)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,NumberOfPages,AuthorId,PublisherId")] 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))); } ViewData["AuthorId"] = new SelectList(_context.Author, "Id", "Name", book.AuthorId); ViewData["PublisherId"] = new SelectList(_context.Publisher, "Id", "Name", book.PublisherId); return(View(book)); }