public async void SearchCommandExecuted(object param) { _searchingDb = true; DatabaseSearchResults.Clear(); if (String.IsNullOrEmpty(FirstName.Trim())) { FirstName = String.Empty; } if (String.IsNullOrEmpty(LastName.Trim())) { FirstName = String.Empty; } if (String.IsNullOrEmpty(StreetAddress.Trim())) { StreetAddress = String.Empty; } if (String.IsNullOrEmpty(City.Trim())) { City = String.Empty; } if (String.IsNullOrEmpty(ZipCode.Trim())) { ZipCode = String.Empty; } Parallel.ForEach((await DatabaseStuff.RunQuery(FirstName, LastName, (UseDateOfBirth ? DateOfBirth : DateTime.MinValue), DobEqual, DobAfter, DobBefore, StreetAddress, City, ZipCode)), personModel => Application.Current.Dispatcher.BeginInvoke(new Action(() => DatabaseSearchResults.Add(personModel) )) ); _searchingDb = false; }
private async void RunSpouseQuery(FacebookLinkModel facebookLinkModel) { if (!String.IsNullOrEmpty(facebookLinkModel.MarriedTo)) { facebookLinkModel.PossibleSpouseLinks = await DatabaseStuff.RunQuery(facebookLinkModel.SpouseFirstName, facebookLinkModel.SpouseLastName, facebookLinkModel.CurrentCity); } }
public async void SearchVoterDBCommandExecuted(object args) { FacebookLinkModel facebookLinkModel = args as FacebookLinkModel; if (facebookLinkModel == null || String.IsNullOrEmpty(facebookLinkModel.CurrentCity) || String.IsNullOrEmpty(facebookLinkModel.CurrentCity)) { MessageBox.Show("You must first scrape facebook before doing sub operations"); return; } IsLoading = true; SelectedFacebookLinkModel = facebookLinkModel; facebookLinkModel.PossibleLinks = await DatabaseStuff.RunQuery(facebookLinkModel.FirstName, facebookLinkModel.LastName, facebookLinkModel.CurrentCity); RunSpouseQuery(facebookLinkModel); if (facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleSpouseLinks != null && facebookLinkModel.PossibleLinks.Count > 0 && facebookLinkModel.PossibleSpouseLinks.Count > 0) { bool matched = false; foreach (PersonModel possibleLink in facebookLinkModel.PossibleLinks) { if (matched) { break; } foreach (PersonModel possibleSpouseLink in facebookLinkModel.PossibleSpouseLinks) { if (possibleLink.address == possibleSpouseLink.address) { facebookLinkModel.VoterDBMatch = possibleLink; facebookLinkModel.SouseVoterDBMatch = possibleSpouseLink; matched = true; } } } } IsLoading = false; }