Ejemplo n.º 1
0
        /// <summary>
        /// Get the last race data.
        /// </summary>
        /// <returns>Last race data.</returns>
        public async Task <Race> GetLastRaceAsync()
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.LastRace());

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

                    return(JsonConvert.DeserializeObject <DataErgastRaces>(DataErgast.RemoveMRData(content))?.RaceTable?.Races[0]);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\tERROR {0}", ex.Message);
            }

            return(null);
        }