Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. IEnumerable<Transaccion> transaccion = null;
  2.  
  3.             using (var client = new HttpClient())
  4.             {
  5.                 client.BaseAddress = new Uri(Baseurl);
  6.                 //HTTP GET
  7.                 var responseTask = client.GetAsync("Usuario/" + id + "/Transacciones");
  8.                 responseTask.Wait();
  9.  
  10.                 var result = responseTask.Result;
  11.                 if (result.IsSuccessStatusCode)
  12.                 {
  13.                     var readTask = result.Content.ReadAsAsync<IList<Transaccion>>();
  14.                     readTask.Wait();
  15.  
  16.                     transaccion = readTask.Result;
  17.                 }
  18.                 else //web api sent error response
  19.                 {
  20.                     //log response status here..
  21.  
  22.                     transaccion = Enumerable.Empty<Transaccion>();
  23.  
  24.                     ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
  25.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement