Ejemplo n.º 1
0
        // GET: Statistics/GetChestMeasurementDynamics
        public async Task <ActionResult> GetChestMeasurementDynamics(FilterMeasurementDynamics constraints)
        {
            var user = await userManager.FindByIdAsync(User.Identity.GetUserId());

            var measurementDynamics = statisticsService.
                                      GetChestMeasurementDynamics(user.Id, constraints.From, constraints.To);
            var measurementDynamicsVM = new List <ChartPointViewModel>();

            if (ModelState.IsValid && (constraints.From < constraints.To))
            {
                foreach (var md in measurementDynamics)
                {
                    measurementDynamicsVM.Add(
                        new ChartPointViewModel()
                    {
                        Date  = md.Key.ToString("yyyy-MM-dd"),
                        Value = Math.Round(md.Value, 1)
                    });
                }
            }
            return(Json(measurementDynamicsVM, JsonRequestBehavior.AllowGet));
        }