public async Task <IActionResult> Edit(int id, [Bind("SageId,Name,Age,Photo,City")] Sage sage) { if (id != sage.SageId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { // if (!MovieExists(sage.SageId)) // { // return NotFound(); // } // else // { // throw; // } } return(RedirectToAction("Index")); } return(View(sage)); }
public async Task <ActionResult <Book> > Post(Book book) { _context.Books.Add(book); await _context.SaveChangesAsync(); //return CreatedAtAction("GetTodoItem", new { id = todoItem.Id }, todoItem); return(CreatedAtAction(nameof(Get), new { id = book.BookId }, book)); }