async void SelectFBUserPage_FacebookUserSelected(object sender, Models.FacebookUser e) { var selectedContact = (PhoneContact)listView.SelectedItem; //get the booksync contact var booksyncContact = BookSyncContactsHelper.BookSyncContacts.FirstOrDefault(f => f.PhoneContactId == selectedContact.PhoneContactId); booksyncContact.FacebookUserId = e.ID; booksyncContact.FacebookFirstName = e.FirstName; booksyncContact.FacebookLastName = e.LastName; booksyncContact.FacebookImageSmallUrl = e.ProfileImageSmallUrl; booksyncContact.FacebookImageLargeUrl = e.ProfileImageLargeUrl; await BookSyncContactsHelper.SaveBookSyncContacts(); viewModel.UnMatchedContacts.Remove(viewModel.UnMatchedContacts. FirstOrDefault(w => w.PhoneContactId == selectedContact.PhoneContactId)); await Navigation.PopModalAsync(); viewModel.UnMatchedContactsChanged(); listView.SelectedItem = null; }
public async Task ExecuteAcceptMatchesCommand() { //for each selected match update the master list of booksync contacts and save to json var selectedMatches = AutoMatchedContacts.Where(w => w.IsSelected); if (!selectedMatches.Any()) { return; } //loop through the matches and store them then refresh the list. foreach (var selectedContact in selectedMatches) { var booksyncContact = BookSyncContactsHelper.BookSyncContacts.FirstOrDefault(f => f.PhoneContactId == selectedContact.PhoneContactId); booksyncContact.FacebookUserId = selectedContact.FacebookUserId; booksyncContact.FacebookFirstName = selectedContact.FacebookFirstName; booksyncContact.FacebookLastName = selectedContact.FacebookLastName; booksyncContact.FacebookImageSmallUrl = selectedContact.FacebookImageSmallUrl; booksyncContact.FacebookImageLargeUrl = selectedContact.FacebookImageLargeUrl; await BookSyncContactsHelper.SaveBookSyncContacts(); } LoadAutoMatchedContacts(); }
private async void AllContactsFinished() { IsSyncing = false; await BookSyncContactsHelper.SaveBookSyncContacts(); //wait a second and then reset await Task.Delay(500); LoadContacts(); SyncComplete?.Invoke(this, new EventArgs()); }
private async void AllContactsFinished() { //once all completed then save the contacts await BookSyncContactsHelper.SaveBookSyncContacts(); SyncCompleted = true; if (syncExceptions.Any()) { Information = $"{syncExceptions.Count()} of {ContactsToSync.Count()} Contacts Failed to Update"; } else { Information = $"{ContactsToSync.Count()} Contacts Updated"; } }
async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e) { var selectedMatchedContact = (BookSyncContact)e.Item; var bookSyncContact = BookSyncContactsHelper.BookSyncContacts. FirstOrDefault(f => f.PhoneContactId == selectedMatchedContact.PhoneContactId); bookSyncContact.FacebookUserId = string.Empty; bookSyncContact.FacebookFirstName = string.Empty; bookSyncContact.FacebookLastName = string.Empty; bookSyncContact.FacebookImageSmallUrl = string.Empty; bookSyncContact.FacebookImageLargeUrl = string.Empty; bookSyncContact.StoredFacebookImageUrl = string.Empty; bookSyncContact.ShowFacebookImage = true; bookSyncContact.SyncFailed = false; bookSyncContact.SyncCompleted = false; bookSyncContact.IsSyncing = false; //var matchedGroup = viewModel.MatchedContacts.FirstOrDefault(f => // f.Items.FirstOrDefault(c => c.PhoneContactId == bookSyncContact.PhoneContactId) != null); //matchedGroup.Remove(matchedGroup.FirstOrDefault(f => f.PhoneContactId == bookSyncContact.PhoneContactId)); //viewModel.MatchedContacts.Remove(matchedContact); await BookSyncContactsHelper.SaveBookSyncContacts(); //viewModel.MatchedContacts.Remove(viewModel.MatchedContacts.FirstOrDefault(w => w.Key == selectedMatchedContact.PhoneName[0].ToString().ToUpperInvariant()). //FirstOrDefault(f => f.PhoneContactId == selectedMatchedContact.PhoneContactId).PhoneContactId); var matchedContact = viewModel.MatchedContacts.FirstOrDefault(f => f.PhoneContactId == bookSyncContact.PhoneContactId); viewModel.MatchedContacts.Remove(matchedContact); await BookSyncContactsHelper.SaveBookSyncContacts(); viewModel.CheckMatchedContacts(); listView.SelectedItem = null; }