private bool RefreshAndSave() { if (refreshAlternating) { System.Diagnostics.Debug.WriteLine("RefreshAndSave"); Task.Run(async() => { //foreach (User u in App.Users) { await HttpRequests.PostUserEdit(u); } await HttpRequests.extaractUsers(); }).ContinueWith((end) => { Device.BeginInvokeOnMainThread(() => { if (SearchBar.Text != "" && SearchBar.Text != null) { InfoList.ItemsSource = App.Users.AsEnumerable().Where(i => i.name.ToLower().Contains(SearchBar.Text.ToLower())); } else { InfoList.ItemsSource = App.Users; } InfoList.EndRefresh(); }); }); } else { System.Diagnostics.Debug.WriteLine("Save"); //Task.Run(async () => { foreach (User u in App.Users) { await HttpRequests.PostUserEdit(u); } }); } refreshAlternating = !refreshAlternating; return(App.Foreground); }
private bool Refresh() { System.Diagnostics.Debug.WriteLine("Refresh"); Task.Run(async() => await JsonRequests.getUsers()) .ContinueWith((end) => { Device.BeginInvokeOnMainThread(() => { if (SearchBar.Text != "" && SearchBar.Text != null) { InfoList.ItemsSource = getItems().AsEnumerable().Where(i => i.name.ToLower().Contains(SearchBar.Text.ToLower())); } else { InfoList.ItemsSource = getItems(); } InfoList.EndRefresh(); }); }); return(App.Foreground); }