async Task GetUserAsync(string id) { //If it's already getting the data, don't get the data. if (IsBusy) { return; } try { IsBusy = true; User getUser = await DataService.GetUserAsync("5e93600fd89dee0bdd199f47"); if (getUser != null) { User = getUser; //From mvvmhelpers: Feines.ReplaceRange(getUser.Tasks); FeinesSearch.ReplaceRange(getUser.Tasks); Title = $"{Feines.Count} feines"; if (getUser != null) { //Save to persistence LocalDataService.SaveUserAsync(getUser); } } } catch (Exception ex) { Debug.WriteLine($"Unable to get user: {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } finally { IsBusy = false; } }
async void SearchTasks(string search) { if (Feines == null || IsBusy) { return; } try { var searchList = Feines.Where((f) => f.Name.ToLower().Contains(search.ToLower()) || f.ClientName.ToLower().Contains(search.ToLower()) || f.Land.Name.ToLower().Contains(search.ToLower())); FeinesSearch.ReplaceRange(searchList); Title = $"{FeinesSearch.Count} feines"; } catch (Exception ex) { Debug.WriteLine($"Error while searching {ex.Message}"); await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK"); } }