public async Task <IHttpActionResult> PutBook(int id, Book book) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != book.BookId) { return(BadRequest()); } db.MarkAsModified(book); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(Content(HttpStatusCode.Accepted, book)); }
public async Task <IHttpActionResult> PutAuthor(int id, Author author) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != author.AuthorId) { return(BadRequest()); } db.MarkAsModified(author); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(id)) { return(NotFound()); } else { throw; } } return(Content(HttpStatusCode.Accepted, author)); }