private async Task CheckIfGameIsOverAndSetFinalResultIfNecessary(LiveMatchStats liveMatchStats)
        {
            if (liveMatchStats != null && (liveMatchStats.MatchStatus == MatchStatus.ApiCancelled || liveMatchStats.MatchStatus == MatchStatus.FullTime))
            {
                var arsenal            = GetArsernal();
                var resultFullTimeSave = await arsenal.AddFullTimeLiveMatchStats(exceptionNotifier, rootAggregateRepositorySingletonFootballTeams, liveMatchStats);

                if (resultFullTimeSave.Succeeded)
                {
                    matchesForLiveBroadcast = arsenal.JSListOfFootBallMatch_Matches.DeserializeFromJson <List <FootBallMatch> >();
                    currentFootballMatch    = null;
                }
            }
        }
Beispiel #2
0
 public LiveMatchViewModel(FootBallMatch footBallMatch, LiveMatchStats liveMatchStats)
 {
     AwayTeamLogo            = footBallMatch.AwayTeamLogoUrl;
     HomeTeamLogo            = footBallMatch.HomeTeamLogoUrl;
     AwayTeamName            = footBallMatch.AwayTeamName;
     HomeTeamName            = footBallMatch.HomeTeamName;
     GoalsAwayTeam           = liveMatchStats.GoalsScoredAwaySide;
     GoalsHomeTeam           = liveMatchStats.GoalsScoredHomeSide;
     MatchId                 = liveMatchStats.MatchId;
     MatchStatus             = liveMatchStats.MatchStatus.ToString();
     Minute                  = liveMatchStats.Minute;
     PenaltiesScoredAwayTeam = liveMatchStats.PenaltiesScoredAwaySide;
     PenaltiesScoredHomeTeam = liveMatchStats.PenaltiesScoredHomeSide;
     StartTime               = footBallMatch.TimeOfMatch;
 }
Beispiel #3
0
        public LiveMatchViewModel(FootBallMatch footBallMatch)
        {
            AwayTeamLogo = footBallMatch.AwayTeamLogoUrl;
            HomeTeamLogo = footBallMatch.HomeTeamLogoUrl;
            AwayTeamName = footBallMatch.AwayTeamName;
            HomeTeamName = footBallMatch.HomeTeamName;
            StartTime    = footBallMatch.TimeOfMatch;

            GoalsAwayTeam           = footBallMatch.FullTimeMatchStats?.GoalsScoredAwaySide ?? 0;
            GoalsHomeTeam           = footBallMatch.FullTimeMatchStats?.GoalsScoredHomeSide ?? 0;
            MatchId                 = footBallMatch.MatchId;
            MatchStatus             = footBallMatch.FullTimeMatchStats?.MatchStatus.ToString() ?? Domain.MatchStatus.NotStarted.ToString();
            Minute                  = footBallMatch?.FullTimeMatchStats?.Minute ?? "0";
            PenaltiesScoredAwayTeam = footBallMatch?.FullTimeMatchStats?.PenaltiesScoredAwaySide ?? 0;
            PenaltiesScoredHomeTeam = footBallMatch?.FullTimeMatchStats?.PenaltiesScoredHomeSide ?? 0;
        }
        public async void LiveMatchResults(object state)
        {
            if (!isProcessingMatch)
            {
                isProcessingMatch = true;
                try
                {
                    await SetPreviouslyPlayedGameResults();

                    if (currentFootballMatch == null || currentFootballMatch.TimeOfMatchPlus5Hours < DateTime.Now)
                    {
                        currentFootballMatch = null;

                        if (matchesForLiveBroadcast?.Any() ?? false)
                        {
                            matchesForLiveBroadcast = matchesForLiveBroadcast.OrderBy(m => m.TimeOfMatch).ToList();
                            currentFootballMatch    = matchesForLiveBroadcast.FirstOrDefault(m => m.TimeOfMatchPlus5Hours > DateTime.UtcNow && m.FullTimeMatchStats == null);
                        }
                    }

                    if (currentFootballMatch != null && currentFootballMatch.FullTimeMatchStats == null && currentFootballMatch.TimeOfMatch <= DateTime.UtcNow)
                    {
                        var response = await footBallWorker.GetLiveDataForMatch(currentFootballMatch.MatchId);

                        if (response.Succeeded)
                        {
                            Log.Logger.Information("{@response}", response.ReturnedObject);
                            await SendMatchUpdate(response.ReturnedObject);
                            await CheckIfGameIsOverAndSetFinalResultIfNecessary(response.ReturnedObject);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ;
                }
                finally
                {
                    isProcessingMatch = false;
                }
            }
        }
Beispiel #5
0
 private void FillRoster()
 {
     roster.Clear();
     for (int i = 0; i < teams.Count; i++)     //home team index
     {
         var row = new List <FootBallMatch>(); //these are all the matches for the home team
         for (int j = 0; j < teams.Count; j++) //away team index
         {
             if (i == j)
             {
                 row.Add(null);//As defined above, a Match is null when Home team plays itself
             }
             else
             {
                 var match = new FootBallMatch();
                 match.Home = teams[i];
                 match.Away = teams[j];
                 row.Add(match);
             }
         }
         roster.Add(row);
     }
 }