private void LoadMatchedContacts() { hasLoaded = false; OnPropertyChanged(nameof(HasContacts)); MatchedContacts.Clear(); var matchedContacts = BookSyncContactsHelper.BookSyncContacts.Where(w => !string.IsNullOrEmpty(w.FacebookUserId)) .OrderBy(o => o.PhoneName).ToList(); foreach (var contact in matchedContacts) { MatchedContacts.Add(contact); } //Only want to group by blank and A-Z //var sorted = from item in BookSyncContactsHelper.BookSyncContacts //where !string.IsNullOrEmpty(item.FacebookUserId) //orderby item.PhoneName //group item by ((item.PhoneName[0] > 64 && item.PhoneName[0] < 91) || (item.PhoneName[0] > 96 && item.PhoneName[0] < 123) ? // item.PhoneName[0].ToString().ToUpperInvariant() : string.Empty) into itemGroup //select new Grouping<string, BookSyncContact>(itemGroup.Key, itemGroup); //MatchedContacts.ReplaceRange(sorted); //int index = MatchedContacts.Count() - 1; //for (int i = 90; i > 64; i--) //{ // if (index < 0) // { // MatchedContacts.Insert(0, new Grouping<string, BookSyncContact>(((char)i).ToString(), new List<BookSyncContact>())); // } // else // { // var currentRecord = MatchedContacts[index]; // char character = currentRecord.Key[0]; // if (i != character) // { // //need to insert a blank record // MatchedContacts.Insert(index + 1, new Grouping<string, BookSyncContact>(((char)i).ToString(), new List<BookSyncContact>())); // } // else // { // index--; // } // } //} CheckMatchedContacts(); }
public void CheckMatchedContacts() { if (!MatchedContacts.Any()) { Information = "There are no matched contacts."; int unMatchedCount = BookSyncContactsHelper.BookSyncContacts.Where(w => string.IsNullOrEmpty(w.FacebookUserId)).Count(); if (unMatchedCount > 0) { SubInformation = $"You have {unMatchedCount} unmatched contacts."; } } hasLoaded = true; OnPropertyChanged(nameof(HasContacts)); OnPropertyChanged(nameof(HasUnMatchedContacts)); }