public async Task <GetHRBoundsMsg> GetHRBounds(UsernameData data) { GetHRBoundsMsg msg = new GetHRBoundsMsg(); Biometric bio = null; try { bio = await _bio.GetMostRecentRecord(data); } catch (Exception e) { throw new CustomException("Error getting HR data in service" + e); } int age = CalculateAge(bio.dob); int resting = await GetRestingHeartRate(data); msg.maxHR = 220 - age; msg.heartRateReserve = msg.maxHR - resting; double seventy = msg.heartRateReserve * 0.7 + resting; double eightFive = msg.heartRateReserve * 0.85 + resting; msg.targetHR = Math.Round((seventy + eightFive) / 2, 0); return(msg); }
public async Task <IActionResult> GetHRBounds([FromBody] UsernameData data) { GetHRBoundsMsg msg = null; try { msg = await _BiometricService.GetHRBounds(data); } catch (Exception) { return(BadRequest()); } return(Ok(msg)); }