public async Task <IActionResult> Post([FromBody] MedicalSensorData body) { var user = _context.Users.Include(ApplicationUser => ApplicationUser.MedicalSensorData) .Single(u => u.Email == body.UserEmail); if (user != null) { user.MedicalSensorData.Add(new MedicalSensorData() { UserEmail = body.UserEmail, ECG = body.ECG, SpO2 = body.SpO2, Respiration = body.Respiration, Pulse = body.Pulse, BloodPressure = body.BloodPressure, health = body.health }); await _context.SaveChangesAsync(); } //Get User //Save MedicalSensorData entry to user return(Ok()); }
private SkillResponse medicalDataIntent(ApplicationUser user, Fulfillment fulfillment, AlexaSession session) { //Update skill-specific fulfillment info fulfillment.Note = "User requested Medical Data Update"; fulfillment.Category = FulfillmentCategory.Safety; fulfillment.Status = FulfillmentStatus.Fulfilled; user.AlexaSessions.Add(session); user.Fulfillments.Add(fulfillment); _context.SaveChanges(); var medicalResponse = new Alexa.NET.Response.SsmlOutputSpeech(); MedicalSensorData medicalData = user.MedicalSensorData.Last(); string healthString = ""; if (medicalData != null) { if (medicalData.health == true) { healthString = "You are healthy!"; medicalResponse.Ssml = "<speak>" + healthString + "</speak>"; } else { healthString = "You aren't healthy."; medicalResponse.Ssml = "<speak>" + healthString + "</speak>"; } return(ResponseBuilder.Tell(medicalResponse)); } else { medicalResponse.Ssml = "<speak>" + "An error occured, please try again." + "</speak>"; } return(ResponseBuilder.Tell(medicalResponse)); }