private async Task CustomerSearch() { Address addr = new Address(); if (Search != null) { var searchResults = AllAddresses.Where(address => addr.Compare(address, Search)); AddressList.Clear(); AddressList.AddRange(searchResults); } }
void LoadDefaultList() { if (_isShowingFilteredList) { //Needed to prevent a race condition where LoadDefaultList would be called right after we set the filtered places list. _isShowingFilteredList = false; return; } using (this.Services().Message.ShowProgressNonModal()) { AllAddresses.Clear(); ShowDefaultResults = true; AllAddresses.AddRange(_defaultFavoriteAddresses.Concat(_defaultHistoryAddresses).Concat(_defaultNearbyPlaces)); } }
public async Task SearchAddress(string criteria) { if (_ignoreTextChange) { return; } if (criteria.HasValue() && criteria != StartingText && criteria != _previousPostCode) { using (this.Services().Message.ShowProgressNonModal()) { ShowDefaultResults = false; AllAddresses.Clear(); var fhAdrs = SearchFavoriteAndHistoryAddresses(criteria); var pAdrs = Task.Run(() => SearchPlaces(criteria)); var gAdrs = Task.Run(() => SearchGeocodeAddresses(criteria)); if (this.Services().Settings.CraftyClicksApiKey.HasValue() && _postalCodeService.IsValidPostCode(criteria)) { var ccAdrs = SearchPostalCode(criteria); _previousPostCode = criteria; AllAddresses.AddRangeDistinct(await ccAdrs, (x, y) => x.Equals(y)); } AllAddresses.AddRangeDistinct(await fhAdrs, (x, y) => x.Equals(y)); if (char.IsDigit(criteria[0])) { AllAddresses.AddRangeDistinct(await gAdrs, (x, y) => x.Equals(y)); AllAddresses.AddRangeDistinct(await pAdrs, (x, y) => x.Equals(y)); } else { AllAddresses.AddRangeDistinct(await pAdrs, (x, y) => x.Equals(y)); AllAddresses.AddRangeDistinct(await gAdrs, (x, y) => x.Equals(y)); } } } else { LoadDefaultList(); } }
public Task LoadAllAddresses() { using (this.Services().Message.ShowProgress()) { var tasks = new [] { LoadFavoriteAddresses(), LoadHistoryAddresses() }; return(Task.Factory.ContinueWhenAll(tasks, t => { AllAddresses.Clear(); AllAddresses.Add(new AddressViewModel { Address = new Address { FriendlyName = this.Services().Localize["LocationAddFavoriteTitle"], FullAddress = this.Services().Localize["LocationAddFavoriteSubtitle"], }, IsAddNew = true, ShowPlusSign = true }); if (t[0].Status == TaskStatus.RanToCompletion) { AllAddresses.AddRange(t[0].Result); } if (t[1].Status == TaskStatus.RanToCompletion) { AllAddresses.AddRange(t[1].Result); } AllAddresses.ForEach(a => { a.IsFirst = a.Equals(AllAddresses.First()); a.IsLast = a.Equals(AllAddresses.Last()); }); RaisePropertyChanged(() => AllAddresses); }, new CancellationTokenSource().Token, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext())); } }