public async Task <double> BMIResultAsync(BMIRequest BMIRequest) { BMICalculator calc = new BMICalculator(); calc.Date = DateTime.Now; calc.Id = Guid.NewGuid(); double height = BMIRequest.height; var weight = BMIRequest.weight; calc.Weight = BMIRequest.weight; calc.Height = BMIRequest.height; double Bmi = Math.Round((weight / ((height / 100) * (height / 100))), 1); if (BMIRequest.save == false) { return(Bmi); } calc.Result = Bmi; DbContext.BMIResults.Add(calc); await DbContext.SaveChangesAsync(); return(Bmi); }
public async Task <IActionResult> BmiResult([FromBody] BMIRequest BMIRequest) { var bmiseresult = await BodyInfoService.BMIResultAsync(BMIRequest); return(Ok(bmiseresult)); }