public async Task <IActionResult> Edit(int id, [Bind("id,userId,title,colour,dateCreated,dateUpdated")] 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 async Task <IActionResult> Edit(int id, [Bind("id,title,pageNum,content,bookId,dateCreated,dateUpdated")] Page page) { if (id != page.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(page); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PageExists(page.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["bookId"] = new SelectList(_context.books, "id", "title", page.bookId); return(View(page)); }