public async Task <RootObjectBer> RefreshBerichtAsync(string time) { Uri uri = null; Berichts = new RootObjectBer(); if (time == "week") { uri = new Uri(string.Format(Constants.BerichtReadW, string.Empty)); } if (time == "month") { uri = new Uri(string.Format(Constants.BerichtReadM, string.Empty)); } if (time == "year") { uri = new Uri(string.Format(Constants.BerichtReadY, string.Empty)); } try { var response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); Berichts = JsonConvert.DeserializeObject <RootObjectBer>(content); } } catch (Exception ex) { Debug.WriteLine(@" ERROR {0}", ex.Message); } return(Berichts); }
async void Jahr_Clicked(object sender, EventArgs e) { lstView.BeginRefresh(); restService = new RestService(); RootObjectBer objectBer = new RootObjectBer(); objectBer = await restService.RefreshBerichtAsync("year"); lstView.ItemsSource = objectBer.bericht; lstView.EndRefresh(); }