public ActionResult Details(string id)
        {
            DateTime selectedDate;

            DateTime.TryParse(id, out selectedDate);
            if (string.IsNullOrEmpty(id) || selectedDate == null)
            {
                return(RedirectToAction("Days", "Days"));
            }

            List <History> history = GetAllHistory();

            ChartSeriesHelper.CalculateCalsBurntPerMinBetweenInputs(selectedDate, history);


            var model = history.Where(x => x.IsSameDate(selectedDate)).OrderByDescending(x => x.DateTime).ToList();

            // Calculate the time series
            ViewBag.TIME = ChartSeriesHelper.CalculateTimeSeries();
            // Calculate the selected date series
            ViewBag.CALS = ChartSeriesHelper.CalculateSeries(selectedDate, history, ReturnSeriesOf.CaloriesBurnt);
            // Calculate the same day of last week series
            ViewBag.LAST = ChartSeriesHelper.CalculateSeries(selectedDate.AddDays(-7), history, ReturnSeriesOf.CaloriesBurnt);
            // Calculate the average of this day series
            ViewBag.AVG = ChartSeriesHelper.CalculateAverageSeries(selectedDate, rangeInDays, history, ReturnSeriesOf.CaloriesBurnt);
            // Calculate the average calories per min series
            ViewBag.CPM = ChartSeriesHelper.CalculateSeries(selectedDate, history, ReturnSeriesOf.CaloriesPerMin);
            // Calculate the calories per min series
            ViewBag.AVGCPM = ChartSeriesHelper.CalculateAverageSeries(selectedDate, rangeInDays, history, ReturnSeriesOf.CaloriesPerMin);

            return(View("Details", model));
        }
 public void CalculateSeriesTest()
 {
     double[] caloriesSeries   = ChartSeriesHelper.CalculateSeries(today.AddDays(-1), history, ReturnSeriesOf.CaloriesBurnt);
     double[] calsPerMinSeries = ChartSeriesHelper.CalculateSeries(today.AddDays(-1), history, ReturnSeriesOf.CaloriesPerMin);
     Assert.IsTrue(IsCalories(caloriesSeries));
     Assert.IsTrue(IsCalsPerMin(calsPerMinSeries));
 }
        public void CalculateSeriesTodayTest()
        {
            double[] caloriesSeries = ChartSeriesHelper.CalculateSeries(today, history, ReturnSeriesOf.CaloriesBurnt);

            int mins = (today.Hour * 60) + (today.Minute);

            Assert.IsTrue(caloriesSeries[mins + 10] == 0);
        }