public static async Task <AllCountriesModel> LoadDataForAllCountries() { ApiHelper.InitializeClient(); var url = new Uri(ApiHelper.ApiClient.BaseAddress + "all"); using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url)) { if (response.IsSuccessStatusCode) { AllCountriesModel allData = await response.Content.ReadAsAsync <AllCountriesModel>(); return(allData); } throw new Exception(response.ReasonPhrase); } }
protected List <AllCountriesModel> ListOfCountries(string json) { var finalJSON = string.Empty; dynamic data = GetDynamicObjectFromJson(json); List <AllCountriesModel> lstCountries = new List <AllCountriesModel>(); for (int i = 0; i < data.Count; i++) { AllCountriesModel country = new AllCountriesModel(); country.Name = data[i].name; country.Region = data[i].region; country.Subregion = data[i].subregion; lstCountries.Add(country); } return(lstCountries); }