/// <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)); } } }
/// <summary> /// remove the initial row used to enter the 'candidate' SSN etc which lead to choosing someone from the existing customer list and is now getting added (and therefore takes the place of this temporary row) /// </summary> /// <returns></returns> private bool DropInMemAddMember() { var simpleDrop = HouseMembers.Cast <DataRowView>().FirstOrDefault(r => r.Row.RowState == DataRowState.Added); if (simpleDrop == null) { return(false); } simpleDrop.DetachRow(); return(true); }
public static async Task <MemberViewModel> HouseMemberByAddress(string address) { var district = await API.HouseDistrictByAddress(address); if (!string.IsNullOrEmpty(district)) { var split = district.Split('/'); return(HouseMembers.First(m => m.State.Equals(split.First(), StringComparison.OrdinalIgnoreCase) && m.District.Equals(split.Last()))); } else { return(null); } }
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)); } }); }
protected override void UnLoadSubClass() { if (SponsorRemarks != null) { SponsorRemarks.Table.RowChanged -= SponsorRemarksRowChanged; } if (ClientTable != null) { ClientTable.ColumnChanged -= ClientTableColumnChanged; ClientTable.RowChanged -= ClientTableRowChanged; } if (_potentialClientMatchesBgWorker != null) { _potentialClientMatchesBgWorker.OnExecute = null; _potentialClientMatchesBgWorker.OnCompleted = null; } UTAPFields.DetachRow(); TaxForms.DetachRowsAndDispose(); HouseMembers.DetachRowsAndDispose(); SponsorRemarks.DetachRowsAndDispose(); }
protected override bool SaveSubClass() { //validate everything first so we see all the red boxes at once... var isValid = true; ValidateGeneric(ref isValid, "Rank"); ValidateGeneric(ref isValid, "DEROS"); ValidateGeneric(ref isValid, "DutyLocation"); ValidateGeneric(ref isValid, "DutyPhoneDSN1", "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(ref isValid, "DutyPhoneDSN2", "'?'.Length == 4", "Enter 4 Digits"); ValidateGeneric(ref isValid, "OfficialMailCMR"); ValidateGeneric(ref isValid, "OfficialMailBox"); ValidateGeneric(ref isValid, "OfficialMailCity"); ValidateGeneric(ref isValid, "OfficialMailState"); ValidateGeneric(ref isValid, "OfficialMailZip", "'?'.Length == 5", "Enter 5 Digits"); ValidateGeneric(ref isValid, "HomePhoneCountry"); ValidateGeneric(ref isValid, "HomePhone"); var validateUTAP = Fields.Field <bool>("IsUTAPActive"); ValidateGeneric(Fields, ref isValid, "HomeStreet,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeStreetNumber,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeCity,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomePostal,IsUTAPActive", validateUTAP); foreach (DataRowView member in HouseMembers) { ValidateGeneric(member, ref isValid, "SSN1", true, "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(member, ref isValid, "SSN2", true, "'?'.Length == 2", "Enter 2 Digits"); ValidateGeneric(member, ref isValid, "SSN3", true, "'?'.Length == 4", "Enter 4 Digits"); if (ValidateGeneric(member, ref isValid, "FName")) { ValidateGeneric(member, ref isValid, "FName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); } if (ValidateGeneric(member, ref isValid, "LName")) { ValidateGeneric(member, ref isValid, "LName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); } } if (!isValid) { ShowUserMessage("Please correct all highlighted fields before saving."); return(false); } //then save attempt to save everything if we made it through all the validation... if (Fields.IsDirty()) { if (!SaveJustSponsorRecord()) { return(false); } } foreach (var member in HouseMembers.Cast <DataRowView>().Where(member => member.IsDirty())) { // ReSharper disable InconsistentNaming using (Proc Client_u = new iTRAACProc("Client_u")) // ReSharper restore InconsistentNaming { Client_u.AssignValues(member); if (!Client_u.ExecuteDataSet(UserMessagePrefix)) { return(false); } member.AcceptChanges(); CacheTables(Client_u); } } RemarkModel.SaveRemarks("SponsorGUID", GUID, UserMessagePrefix, SponsorRemarks); return(true); }