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 CalculateAverageSeriesTest()
 {
     double[] averageCalories   = ChartSeriesHelper.CalculateAverageSeries(today, TestSettings.rangeInDays, history, ReturnSeriesOf.CaloriesBurnt);
     double[] averageCalsPerMin = ChartSeriesHelper.CalculateAverageSeries(today, TestSettings.rangeInDays, history, ReturnSeriesOf.CaloriesPerMin);
     Assert.IsTrue(IsCalories(averageCalories));
     Assert.IsTrue(IsCalsPerMin(averageCalsPerMin));
 }