Exemple #1
0
        public async Task <LigaContract> GetLigaAsync(string Liga)
        {
            using (HttpClient HttpClient = new HttpClient())
            {
                HttpClient.DefaultRequestHeaders.Accept.Clear();
                HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await HttpClient.GetAsync(Liga);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        List <LigaContract> lig = await response.Content.ReadAsAsync <List <LigaContract> >();

                        _ligaContract = lig[0];
                    }
                    catch (System.Exception)
                    {
                        _unranked = new Unranked(_perfilContract.GetSummonerContract().Id,
                                                 _perfilContract.GetSummonerContract().Name);
                        _ligaContract = _unranked;
                    }
                }
            }
            return(_ligaContract);
        }
Exemple #2
0
 public LoLService(SummonerContract summonerContract, PerfilContract perfilContract,
                   LigaContract ligaContract, LoLStatsContext context, Perfil perfil)
 {
     _perfil           = perfil;
     _context          = context;
     _summonerContract = summonerContract;
     _ligaContract     = ligaContract;
     _perfilContract   = perfilContract;
 }