public IHttpActionResult PutCaus(int id, Caus caus) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != caus.Cause_ID) { return(BadRequest()); } db.Entry(caus).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CausExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCaus(int id) { db.Configuration.ProxyCreationEnabled = false; Caus caus = db.Causes.Find(id); if (caus == null) { return(NotFound()); } return(Ok(caus)); }
public IHttpActionResult PostCaus(Caus caus) { db.Configuration.ProxyCreationEnabled = false; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Causes.Add(caus); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = caus.Cause_ID }, caus)); }
public IHttpActionResult DeleteCaus(int id) { db.Configuration.ProxyCreationEnabled = false; Caus caus = db.Causes.Find(id); if (caus == null) { return(NotFound()); } db.Causes.Remove(caus); db.SaveChanges(); return(Ok(caus)); }