public async Task <IHttpActionResult> PutDetectDrowsiness(long id, DetectDrowsiness detectDrowsiness) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != detectDrowsiness.Id) { return(BadRequest()); } db.Entry(detectDrowsiness).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetectDrowsinessExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetDetectDrowsiness(long id) { DetectDrowsiness detectDrowsiness = await db.DetectDrowsinesses.FindAsync(id); if (detectDrowsiness == null) { return(NotFound()); } return(Ok(detectDrowsiness)); }
public async Task <IHttpActionResult> GetLastDetection() { int last = await db.DetectDrowsinesses.CountAsync(); DetectDrowsiness detectDrowsiness = await db.DetectDrowsinesses.FindAsync(last); if (detectDrowsiness == null) { return(NotFound()); } return(Ok(detectDrowsiness)); }
public async Task <IHttpActionResult> DeleteDetectDrowsiness(long id) { DetectDrowsiness detectDrowsiness = await db.DetectDrowsinesses.FindAsync(id); if (detectDrowsiness == null) { return(NotFound()); } db.DetectDrowsinesses.Remove(detectDrowsiness); await db.SaveChangesAsync(); return(Ok(detectDrowsiness)); }
public async Task <IHttpActionResult> PostDetectDrowsiness(DetectDrowsiness detectDrowsiness) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var hub = GlobalHost.ConnectionManager.GetHubContext <MyHub>(); hub.Clients.All.broadcastMessage("Drowsiness", detectDrowsiness.IsAwake); db.DetectDrowsinesses.Add(detectDrowsiness); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = detectDrowsiness.Id }, detectDrowsiness)); }