public async Task<IHttpActionResult> PutChange(int id, Change change) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != change.Id) { return BadRequest(); } db.Entry(change).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChangeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostChange(Change change) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Changes.Add(change); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = change.Id }, change); }