コード例 #1
0
        public IActionResult Create([Bind("Id,Systolic,Diastolic")] Measurement measurement)
        {
            if (ModelState.IsValid)
            {
                if (measurement.Systolic > 180 || measurement.Diastolic > 120)
                {
                    measurement.Category   = Category.HighpertensiveCrisis;
                    measurement.Suggestion = Suggestion.HighpertensiveCrisis;
                }
                else if (measurement.Systolic >= 140 || measurement.Diastolic >= 90)
                {
                    measurement.Category = Category.HypertensionStage2;
                }
                else if ((measurement.Systolic >= 130 && measurement.Systolic <= 139) || (measurement.Diastolic >= 80 && measurement.Diastolic <= 89))
                {
                    measurement.Category = Category.HypertensionStage1;
                }
                else if ((measurement.Systolic >= 120 && measurement.Systolic <= 129) && (measurement.Diastolic < 80))
                {
                    measurement.Category   = Category.Elevated;
                    measurement.Suggestion = Suggestion.Elevated;
                }
                else if (measurement.Systolic < 120 && measurement.Diastolic < 80)
                {
                    measurement.Category = Category.Normal;
                }

                measurement.UserID = _userManager.GetUserId(HttpContext.User);
                _measurementRepo.AddNew(measurement);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(measurement));
        }
コード例 #2
0
 public Measurement PostMeasurement(Measurement measurement)
 {
     if (measurement.Systolic > 180 || measurement.Diastolic > 120)
     {
         measurement.Category   = Category.HighpertensiveCrisis;
         measurement.Suggestion = Suggestion.HighpertensiveCrisis;
     }
     else if (measurement.Systolic >= 140 || measurement.Diastolic >= 90)
     {
         measurement.Category = Category.HypertensionStage2;
     }
     else if ((measurement.Systolic >= 130 && measurement.Systolic <= 139) || (measurement.Diastolic >= 80 && measurement.Diastolic <= 89))
     {
         measurement.Category = Category.HypertensionStage1;
     }
     else if ((measurement.Systolic >= 120 && measurement.Systolic <= 129) && (measurement.Diastolic < 80))
     {
         measurement.Category   = Category.Elevated;
         measurement.Suggestion = Suggestion.Elevated;
     }
     else if (measurement.Systolic < 120 && measurement.Diastolic < 80)
     {
         measurement.Category = Category.Normal;
     }
     measurementRepo.AddNew(measurement);
     return(measurement);
 }