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 CalculateTimeSeriesTest()
        {
            string[] timeSeries = ChartSeriesHelper.CalculateTimeSeries();
            DateTime?lastTime   = null;

            foreach (string str in timeSeries)
            {
                var temp = str.Substring(3, 2);
                int hour = int.Parse(str.Substring(0, 2));
                int min  = int.Parse(str.Substring(3, 2));
                Assert.IsTrue(hour <= 23);
                Assert.IsTrue(min <= 59);
                DateTime time = new DateTime(today.Year, today.Month, today.Day, hour, min, 0);
                if (lastTime != null)
                {
                    Assert.IsTrue(lastTime < time);
                }
                lastTime = new DateTime(time.Year, time.Month, time.Day, hour, min, 0);
            }
        }