SHARE
TWEET

Untitled

a guest Jul 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Populate countryies, states and cities, to populate dropdown lists
  2. var countries = await client.GetAsync("countries");
  3. if (countries.IsSuccessStatusCode)
  4. {
  5.     viewModel.Countries = await countries.Content.ReadAsAsync<List<Country>>();
  6. }
  7.  
  8. var states = await client.GetAsync("states");
  9. if (states.IsSuccessStatusCode)
  10. {
  11.     viewModel.States = await states.Content.ReadAsAsync<List<State>>();
  12. }
  13.  
  14. var cities = await client.GetAsync("cities");
  15. if (cities.IsSuccessStatusCode)
  16. {
  17.     viewModel.Cities = await cities.Content.ReadAsAsync<List<City>>();
  18. }
  19.  
  20. var residues = await client.GetAsync("residues");
  21. if (residues.IsSuccessStatusCode)
  22. {
  23.     viewModel.Residues = await residues.Content.ReadAsAsync<List<SiteResidue>>();
  24. }
  25.  
  26. return View(viewModel);
  27.      
  28. var countriesTask = client.GetAsync("countries");
  29. var statesTask = client.GetAsync("states");
  30. var citiesTask = client.GetAsync("cities");
  31. var residuesTask = client.GetAsync("residues");
  32.  
  33. await Task.WhenAll(countriesTask, statesTask, citiesTask, residuesTask);
  34.  
  35. viewModel.Countries = countriesTask.Result.Content.ReadAsAsync<List<Country>>();
  36. viewModel.States = statesTask.Result.Content.ReadAsAsync<List<State>>();
  37. viewModel.Cities = citiesTask.Result.Content.ReadAsAsync<List<City>>();
  38. viewModel.Residues = residuesTask.Result.Content.ReadAsAsync<List<SiteResidue>>();
  39.  
  40. return View(viewModel);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top