public async Task Update()
        {
            var nextEvents = await _eventRepository.LoadStartedMatches();

            while (nextEvents.Any())
            {
                foreach (var nextEvent in nextEvents)
                {
                    var matchup = OnGoingMatchup.Create(nextEvent);

                    foreach (var team in matchup.Teams)
                    {
                        foreach (var player in team.Players)
                        {
                            var foundMatchForPlayer = await _matchRepository.LoadOnGoingMatchForPlayer(player.BattleTag);

                            if (foundMatchForPlayer != null)
                            {
                                await _matchRepository.DeleteOnGoingMatch(foundMatchForPlayer.MatchId);
                            }
                        }
                    }

                    await _matchRepository.InsertOnGoingMatch(matchup);

                    await _eventRepository.DeleteStartedEvent(nextEvent.Id);
                }

                nextEvents = await _eventRepository.LoadStartedMatches();
            }
        }
Example #2
0
        public async Task Update(MatchFinishedEvent nextEvent)
        {
            if (nextEvent.WasFakeEvent)
            {
                return;
            }
            var matchup = Matchup.Create(nextEvent);
            await _matchRepository.Insert(matchup);

            await _matchRepository.DeleteOnGoingMatch(matchup.MatchId);
        }
Example #3
0
        public async Task Update()
        {
            var nextEvents = await _eventRepository.LoadStartedMatches();

            while (nextEvents.Any())
            {
                foreach (var nextEvent in nextEvents)
                {
                    if (nextEvent.match.gameMode != CommonValueObjects.GameMode.CUSTOM)
                    {
                        var matchup = OnGoingMatchup.Create(nextEvent);

                        foreach (var team in matchup.Teams)
                        {
                            foreach (var player in team.Players)
                            {
                                var foundMatchForPlayer = await _matchRepository.LoadOnGoingMatchForPlayer(player.BattleTag);

                                if (foundMatchForPlayer != null)
                                {
                                    await _matchRepository.DeleteOnGoingMatch(foundMatchForPlayer.MatchId);
                                }

                                var personalSettings = await _personalSettingsRepository.Load(player.BattleTag);

                                if (personalSettings != null)
                                {
                                    player.CountryCode = personalSettings.CountryCode;
                                }
                            }
                        }

                        await _matchRepository.InsertOnGoingMatch(matchup);
                    }

                    await _eventRepository.DeleteStartedEvent(nextEvent.Id);
                }

                nextEvents = await _eventRepository.LoadStartedMatches();
            }
        }
        public async Task Update(MatchFinishedEvent nextEvent)
        {
            try
            {
                if (nextEvent.WasFakeEvent)
                {
                    return;
                }
                var count = await _matchRepository.Count();

                var matchup = Matchup.Create(nextEvent);

                matchup.Number = count + 1;

                await _matchRepository.Insert(matchup);

                await _matchRepository.DeleteOnGoingMatch(matchup.MatchId);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }