public IHttpActionResult PutMorbidity(int id, Morbidity morbidity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != morbidity.MorbidityId) { return(BadRequest()); } db.Entry(morbidity).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MorbidityExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetMorbidity(int id) { Morbidity morbidity = db.Morbidities.Find(id); if (morbidity == null) { return(NotFound()); } return(Ok(morbidity)); }
public IHttpActionResult PostMorbidity(Morbidity morbidity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Morbidities.Add(morbidity); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = morbidity.MorbidityId }, morbidity)); }
public IHttpActionResult DeleteMorbidity(int id) { Morbidity morbidity = db.Morbidities.Find(id); if (morbidity == null) { return(NotFound()); } db.Morbidities.Remove(morbidity); db.SaveChanges(); return(Ok(morbidity)); }