Пример #1
0
 /// <summary>
 /// Update data from API when available
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void APIDataChanged(object sender, PropertyChangedEventArgs e)
 {
     //Update current list of senators
     if (e.PropertyName.Equals(nameof(CongressAPI.Senators)))
     {
         Senators.Clear();
         foreach (var s in API.Senators)
         {
             Senators.Add(new MemberViewModel(s));
         }
         Ready.Set();
     }
     //Update current list of house members
     if (e.PropertyName.Equals(nameof(CongressAPI.HouseMembers)))
     {
         HouseMembers.Clear();
         foreach (var s in API.HouseMembers)
         {
             HouseMembers.Add(new MemberViewModel(s));
         }
         Ready.Set();
     }
     //Update current list of bills
     if (e.PropertyName.Equals(nameof(CongressAPI.AllBills)))
     {
         RecentBills.Clear();
         foreach (var b in API.AllBills)
         {
             RecentBills.Add(new BillViewModel(b));
         }
     }
 }
Пример #2
0
 private void FetchHouseMembers()
 {
     Task.Run(async() =>
     {
         //query current senators
         var data = await Query <RestResult <Chamber> >(ProPublica, "116/house/members.json");
         if (data != null)
         {
             var results = data.Results.First().Members;
             foreach (var s in results)
             {
                 HouseMembers.Add(s);
             }
             OnPropertyChanged(nameof(HouseMembers));
         }
     });
 }