예제 #1
0
        public async Task <GetRangesMsg> GetRanges(UsernameData data)
        {
            GetRangesMsg msg = new GetRangesMsg();
            Biometric    bio = null;

            try
            {
                bio = await _bio.GetMostRecentRecord(data);
            }
            catch (Exception e)
            {
                throw new CustomException("Error getting HR data in service" + e);
            }
            int resting = await GetRestingHeartRate(data);

            int age              = CalculateAge(bio.dob);
            int maxHR            = 220 - age;
            int heartRateReserve = maxHR - resting;

            msg.fiftyPerc   = Math.Round(heartRateReserve * 0.5 + resting, 0);
            msg.sixtyPerc   = Math.Round(heartRateReserve * 0.6 + resting, 0);
            msg.seventyPerc = Math.Round(heartRateReserve * 0.7 + resting, 0);
            msg.eightyPerc  = Math.Round(heartRateReserve * 0.8 + resting, 0);
            msg.ninetyPerc  = Math.Round(heartRateReserve * 0.9 + resting, 0);
            msg.hundPerc    = Math.Round(heartRateReserve * 1.0 + resting, 0);
            return(msg);
        }
예제 #2
0
        public async Task <IActionResult> GetRanges([FromBody] UsernameData data)
        {
            GetRangesMsg msg = null;

            try
            {
                msg = await _BiometricService.GetRanges(data);
            }
            catch (Exception)
            {
                return(BadRequest());
            }
            return(Ok(msg));
        }