コード例 #1
0
        /// <summary>
        /// Gets list of races a constructor has been into, starting by the offset.
        /// </summary>
        /// <param name="constructor">Constructor ID.</param>
        /// <param name="offset">Offset to start in.</param>
        /// <returns>Races info.</returns>
        private async Task <RaceTable> RacesByConstructorFragmentAsync(string constructor, int offset)
        {
            try
            {
                HttpResponseMessage response = await _client.GetAsync(_api.RacesByConstructor(constructor, offset));

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

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