Esempio n. 1
0
        /// <summary>
        /// Gets all the seasons a specific driver has won the Driver WC.
        /// </summary>
        /// <param name="driver">Driver ID.</param>
        /// <returns>Seasons data.</returns>
        public async Task <SeasonTable> GetSeasonsDriverWorldChampionAsync(string driver)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.SeasonWorldChampionByDriver(driver));

                if (response.IsSuccessStatusCode)
                {
                    string content = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <DataErgastSeasons>(DataErgast.RemoveMRData(content))?.SeasonTable);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\tERROR {0}", ex.Message);
            }
            return(null);
        }