Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- namespace EuroMillions
- {
- public class APIReader
- {
- ObservableCollection<Drawn> drawns;
- public APIReader() {
- this.drawns = new ObservableCollection<Drawn>();
- }
- public ObservableCollection<Drawn> getDrawns()
- {
- return drawns;
- }
- public async void getLastDrawnASync()
- {
- var client = new System.Net.Http.HttpClient();
- client.BaseAddress = new Uri("https://nunofcguerreiro.com/");
- var response = await client.GetAsync("api-euromillions-json");
- var drawnsJson = response.Content.ReadAsStringAsync().Result;
- var rootobject = JsonConvert.DeserializeObject<RootObject>(drawnsJson);
- foreach (var drawn_json in rootobject.drawns)
- {
- this.drawns.Add(drawn_json);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement