public async Task <IHttpActionResult> PutDisabilityReason(int id, DisabilityReason disabilityReason) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != disabilityReason.ID) { return(BadRequest()); } db.Entry(disabilityReason).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DisabilityReasonExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetDisabilityReason(int id) { DisabilityReason disabilityReason = await db.DisabilityReasons.FindAsync(id); if (disabilityReason == null) { return(NotFound()); } return(Ok(disabilityReason)); }
public async Task <IHttpActionResult> PostDisabilityReason(DisabilityReason disabilityReason) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DisabilityReasons.Add(disabilityReason); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = disabilityReason.ID }, disabilityReason)); }
public async Task <IHttpActionResult> DeleteDisabilityReason(int id) { DisabilityReason disabilityReason = await db.DisabilityReasons.FindAsync(id); if (disabilityReason == null) { return(NotFound()); } db.DisabilityReasons.Remove(disabilityReason); await db.SaveChangesAsync(); return(Ok(disabilityReason)); }