// PUT api/Books/5 public async Task <IHttpActionResult> PutBook(int id, Book book) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != book.id) { return(BadRequest()); } db.Entry(book).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Put(int id, [FromBody] Genre genre) { genre.GenreId = id; _db.Entry(genre).State = EntityState.Modified; _db.SaveChanges(); }
public void Put(int id, [FromBody] Story story) { story.StoryId = id; _db.Entry(story).State = EntityState.Modified; _db.SaveChanges(); }