[HttpPost] //Define this method as a POST public async Task<IHttpActionResult> RecordNewPlay(Play play) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Plays.Add(play); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = play.Id }, new Models.DTO.Play(play)); }
[HttpPut] //Define this method as a PUT public async Task<IHttpActionResult> EditPlay(int id, Play play) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != play.Id) { return BadRequest(); } db.Entry(play).State = System.Data.Entity.EntityState.Modified; await db.SaveChangesAsync(); return StatusCode(HttpStatusCode.NoContent); }