public static async Task <DealersResponse> GetDealerDataAsync(string dataSetId, int dealerId) { HttpResponseMessage response = await client.GetAsync(client.BaseAddress.AbsoluteUri + string.Format("/api/{0}/dealers/{1}", dataSetId, dealerId)); DealersResponse dealerData = null; if (response.IsSuccessStatusCode) { dealerData = await response.Content.ReadAsAsync <DealersResponse>(); } else { throw new Exception(string.Format("Unabled to retrieve dealer information.\n\n{0}", response.ReasonPhrase)); } return(dealerData); }
private async Task CreateDealerTasksAsync(string datasetId, List <int> dealerIds) { List <Task <DealersResponse> > dTaskList = new List <Task <DealersResponse> >(); foreach (int id in dealerIds) { Task <DealersResponse> vResponse = ProcessURLDealerAsync(datasetId, id); dTaskList.Add(vResponse); } // Await each task. for (int i = 0; i < dTaskList.Count; i++) { DealersResponse dr = await dTaskList[i]; dealerList.Add(dr); } }
/// <summary> /// Calls Dealer API to get Dealer Response /// </summary> /// <param name="datasetId">string</param> /// <param name="dealerId">int</param> /// <returns></returns> public async Task <DealersResponse> GetDealerAsync(string datasetId, int dealerId) { DealersResponse dealersResponse = await dealersApi.GetDealerAsync(datasetId, dealerId); return(dealersResponse); }