public static void Save()
        {
            if (sessionStatistics.Count <= 1)
            {
                return;
            }
            Statistics stats = Statistics.SumUpAverage(sessionStatistics);

            stats.UserId = StudentRepository.Logged.Id;
            stats.Date   = toDate;

            //update if the database contains today's statistics
            if (hasToDayStatistics)
            {
                Database.Update(stats, constraint: $"where Date = '{toDate}' and userId = {StudentRepository.Logged.Id}");

                //replace with updated statistics everytime you save.
                var tarStat = statistics.Where(s => s.Date == toDate).FirstOrDefault();
                if (tarStat != null)
                {
                    statistics.Remove(tarStat);
                    statistics.Add(stats);
                }
            }
            else
            {
                Database.Insert(stats);
                hasToDayStatistics = true;
                statistics.Add(stats);
            }
        }
 public static Statistics GetAverage()
 {
     return(Statistics.SumUpAverage(sessionStatistics));
 }