public IHttpActionResult PutMeasure(int id, Measure measure) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != measure.ID) { return BadRequest(); } db.Entry(measure).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MeasureExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMeasure(Measure measure) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Measure.Add(measure); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = measure.ID }, measure); }