public IHttpActionResult PostActor(Actor actor) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Actors.Add(actor); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = actor.ActorId }, actor); }
public IHttpActionResult PutActor(int id, Actor actor) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != actor.ActorId) { return BadRequest(); } db.Entry(actor).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ActorExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }