// PUT api/Movies/5 public async Task<IHttpActionResult> PutMovie(int id, Movie movie) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != movie.ID) { return BadRequest(); } db.Entry(movie).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return NotFound(); } else { throw; } } return Ok(); }
public async Task<IHttpActionResult> PostMovie(Movie movie) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Movies.Add(movie); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = movie.ID }, movie); }