public async Task <IEnumerable <CauHoi> > GetListCauHoiByID(int maChuDe) { using (var client = new HttpClient()) { GetListCauHoiByIDResponse lst = null; IEnumerable <CauHoi> result = null; client.BaseAddress = new Uri(Constants.URI); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var response = await client.GetAsync(string.Format(Constants.GetListCauHoiByID, maChuDe)); if (response.IsSuccessStatusCode) { lst = await response.Content.ReadAsAsync <GetListCauHoiByIDResponse>(); result = lst.ToModel2(); } return(result); } }
public static IEnumerable <CauHoi> ToModel2(this GetListCauHoiByIDResponse response) { return(response.CauHois); }