Beispiel #1
0
        public async Task <ActionResult <TftGameModel> > GetTftGameAsync(string matchId)
        {
            _logger.LogInformation($"Trying to get last games tft by ID: {matchId}");

            try {
                if (_CompanionsList == null)
                {
                    var Companions = await _CDragonClient.GetAllCampanionsAsync();

                    _CompanionsList = JsonConvert.DeserializeObject <List <TftCampanionsModel> >(Companions);
                    foreach (var item in _CompanionsList)
                    {
                        item.loadoutsIcon = item.loadoutsIcon.Split('/')[6].ToLower();
                    }
                }
                var token     = _settings.GetSection("tft").GetSection("token").Value;
                var GamesUser = await _TftClient.GetGameAsync(token, matchId);

                var Result = JsonConvert.DeserializeObject <TftGameModel>(GamesUser);
                foreach (var participant in Result.info.participants)
                {
                    var Account = await _AccountClient.GetAccountByPuuidAsync(token, participant.puuid);

                    var ResAccount = JsonConvert.DeserializeObject <AccountModel>(Account);
                    participant.name = ResAccount.name;
                    participant.companion.linkPicture = "http://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/assets/loadouts/companions/" + GetPicureCampanion(participant.companion.content_ID);
                }
                return(Result);
            } catch (ApiException exception) {
                _logger.LogInformation($"Echec to get last games tft by ID: {exception.StatusCode}");
                return(StatusCode((int)exception.StatusCode));
            }
            catch (Exception exc)
            {
                _logger.LogInformation($"Critical error: {exc.Message}");
                return(StatusCode(500));
            }
        }