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 CalculateCalsBurntPerMinBetweenInputsTest()
        {
            List <History> todaysHistory = history.Where(x => x.IsSameDate(today)).ToList();

            Assert.IsTrue(todaysHistory.Where(x => x.CaloriesBurntPerMin != 0).Count() == 0);
            ChartSeriesHelper.CalculateCalsBurntPerMinBetweenInputs(today, todaysHistory);
            Assert.IsTrue(todaysHistory.Where(x => x.CaloriesBurntPerMin == 0).Count() == 1);
        }