public async Task <IHttpActionResult> PutAssistiveDevice(int id, AssistiveDevice assistiveDevice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != assistiveDevice.ID) { return(BadRequest()); } db.Entry(assistiveDevice).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssistiveDeviceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PostAssistiveDevice(AssistiveDevice assistiveDevice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AssistiveDevices.Add(assistiveDevice); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (AssistiveDeviceExists(assistiveDevice.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = assistiveDevice.ID }, assistiveDevice)); }
public async Task <IHttpActionResult> GetAssistiveDevice(int id) { AssistiveDevice assistiveDevice = await db.AssistiveDevices.FindAsync(id); if (assistiveDevice == null) { return(NotFound()); } return(Ok(assistiveDevice)); }
public async Task <IHttpActionResult> DeleteAssistiveDevice(int id) { AssistiveDevice assistiveDevice = await db.AssistiveDevices.FindAsync(id); if (assistiveDevice == null) { return(NotFound()); } db.AssistiveDevices.Remove(assistiveDevice); await db.SaveChangesAsync(); return(Ok(assistiveDevice)); }