public static void CheckStatisticsForGame(Statistic statistic, Game game)
 {
     if (statistic.GamesPlayed.FirstOrDefault(g => g.GameName == game.GameName) != null)
     {
         StatisticMethods.AddGameToStatistics(statistic, game);
     }
 }
        public static void AddGameToStatistics(Statistic statistic, Game game)
        {
            var moonDb = new MoonAidAzureContext();

            statistic.GamesPlayed.Add(game);

            moonDb.Entry(statistic).State = EntityState.Modified;
        }
        public static void StopStreamTimer(Statistic statistic)
        {
            var moonDb = new MoonAidAzureContext();

            TimeSpan spanSinceLastCheck = statistic.LastUpdatedStreamTime - DateTime.Now;

            statistic.TotalStreamTime += spanSinceLastCheck;

            statistic.LastUpdatedStreamTime = DateTime.Now;

            moonDb.Entry<Statistic>(statistic).State = EntityState.Modified;
            moonDb.SaveChanges();
        }
        public static void StartStreamTimer(Statistic statistic)
        {
            var moonDb = new MoonAidAzureContext();

            statistic.LastUpdatedStreamTime = DateTime.Now;

            moonDb.Entry<Statistic>(statistic).State = EntityState.Modified;
            moonDb.SaveChanges();

            //var gameInstance = GameInstanceMethods.GetGameInstance(channel.ChannelId, twitchGameName);

            //if (gameInstance.TimeSpanAdded == null)
            //{
            //    TimeSpan spanBetweenFromAndNow = gameInstance.PlayedFrom - DateTime.Now;

            //    gameInstance.TotalTimePlayed = spanBetweenFromAndNow;
            //    gameInstance.TimeSpanAdded = DateTime.Now;
            //}
            //else
            //{
            //    TimeSpan spanSinceLastCheck = gameInstance.TimeSpanAdded - DateTime.Now;
            //    gameInstance.TotalTimePlayed += spanSinceLastCheck;
            //}
        }
 public static TimeSpan CheckTotalStreamTime(Statistic statistic)
 {
     return statistic.TotalStreamTime;
 }