-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShippingDataService.cs
51 lines (46 loc) · 1.61 KB
/
ShippingDataService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using System;
using System.Net.Http.Json;
namespace Infragistics.Samples
{
public class ShippingDataService : IShippingDataService
{
private readonly HttpClient _http;
public ProductDataService(HttpClient http)
{
_http = http;
}
public async Task<List<ShippingDataItem>> GetTable()
{
using HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, new Uri("https://www.igniteui.com/api/orders", UriKind.RelativeOrAbsolute));
using HttpResponseMessage response = await _http.SendAsync(request).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadFromJsonAsync<List<ShippingDataItem>>().ConfigureAwait(false);
}
return new List<ShippingDataItem>();
}
}
public interface IShippingDataService
{
Task<List<ShippingDataItem>> GetTable();
}
public class ShippingDataItem
{
public int OrderID { get; set; }
public string EmployeeName { get; set; }
public double ShipperID { get; set; }
public string ShipperName { get; set; }
public string CustomerID { get; set; }
public string ContactName { get; set; }
public int TotalItems { get; set; }
public double TotalPrice { get; set; }
public double Freight { get; set; }
public string ShipAddress { get; set; }
public string ShipCountry { get; set; }
public string OrderDate { get; set; }
public string ShipPostalCode { get; set; }
}
}