public IHttpActionResult Putintervention(int id, intervention intervention) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != intervention.ID) { return(BadRequest()); } db.Entry(intervention).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!interventionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Getintervention(int id) { intervention intervention = db.interventions.Find(id); if (intervention == null) { return(NotFound()); } return(Ok(intervention)); }
public IHttpActionResult Postintervention(intervention intervention) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.interventions.Add(intervention); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = intervention.ID }, intervention)); }
public IHttpActionResult Deleteintervention(int id) { intervention intervention = db.interventions.Find(id); if (intervention == null) { return(NotFound()); } db.interventions.Remove(intervention); db.SaveChanges(); return(Ok(intervention)); }