async Task GetClientsAsync() { if (IsBusy) { return; } try { var clients = LocalDataService.GetClients(); if (clients != null) { Clients.ReplaceRange(clients); ClientsSearch.ReplaceRange(clients); IsBusy = false; } } catch (Exception ex) { Debug.WriteLine($"Unable to get clients: {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } finally { IsBusy = false; } }
async void SearchClients(string search) { if (Clients == null || IsBusy) { return; } try { var searchList = Clients.Where((f) => f.Name.ToLower().Contains(search.ToLower())); ClientsSearch.ReplaceRange(searchList); Title = $"{ClientsSearch.Count} clients"; } catch (Exception ex) { Debug.WriteLine($"Error while searching {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } }