public IHttpActionResult PutCause(int id, Cause cause) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != cause.id) { return BadRequest(); } db.Entry(cause).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CauseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCause(Cause cause) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.causes.Add(cause); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = cause.id }, cause); }