Example #1
0
        public async Task Update(MatchFinishedEvent nextEvent)
        {
            foreach (var playerRaw in nextEvent.match.players)
            {
                var player = await _playerRepository.LoadPlayerProfile(playerRaw.battleTag)
                             ?? PlayerOverallStats.Create(playerRaw.battleTag);

                player.RecordWin(
                    playerRaw.race,
                    nextEvent.match.season, playerRaw.won);
                await _playerRepository.UpsertPlayer(player);
            }
        }
        public async Task <IActionResult> GetPlayer([FromRoute] string battleTag, [FromQuery] string authorization)
        {
            var player = await _playerRepository.LoadPlayerProfile(battleTag);

            if (player == null && authorization != null)
            {
                var user = await _authenticationService.GetUserByToken(authorization);

                if (user == null)
                {
                    return(Unauthorized("Sorry Hackerboi"));
                }

                player = PlayerOverallStats.Create(battleTag);
                await _playerRepository.UpsertPlayer(player);
            }

            return(Ok(player));
        }
Example #3
0
        public async Task <IActionResult> GetPlayer([FromRoute] string battleTag, [FromQuery] string authorization)
        {
            var player = await _playerRepository.LoadPlayerProfile(battleTag);

            if (player == null && authorization != null)
            {
                var user = _authenticationService.GetUserByToken(authorization);
                if (user == null)
                {
                    return(Unauthorized("Sorry Hackerboi"));
                }

                player = PlayerOverallStats.Create(battleTag);
            }

            // Akas are stored in cache - preferences for showing akas are stored in DB
            var settings = await _personalSettingsRepository.Load(battleTag);

            player.PlayerAkaData = _playerAkaProvider.GetAkaDataByPreferences(battleTag, settings);

            await _playerRepository.UpsertPlayer(player);

            return(Ok(player));
        }
Example #4
0
 public async Task UpsertPlayer(PlayerOverallStats playerOverallStats)
 {
     await Upsert(playerOverallStats, p => p.BattleTag == playerOverallStats.BattleTag);
 }