public async Task<IHttpActionResult> Put(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 StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> Post(Movie movie) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Movies.Add(movie); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = movie.Id }, movie); }