Example #1
0
        private async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                await App.Current.InitializeDataFromAPI();

                SummaryData = App.AppSummary;
                OnPropertyChanged(nameof(SummaryData));

                ListLocation.Clear();
                ListLocation = new ObservableCollection <CovidLocation>(App.AppLocations);

                ListCluster.Clear();
                ListCluster = new ObservableCollection <CovidCluster>(App.AppClusters);

                OnPropertyChanged(nameof(ListLocation));
                OnPropertyChanged(nameof(ListCluster));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #2
0
        //private async Task GetLocations()
        //{
        //    //how to catch exception or timeout if api unavailable??
        //    var locationsJson = await httpClient.DownloadStringAsync("https://nzcovid19api.xerra.nz/locations/json");
        //    AppLocations = CovidLocation.FromJson(locationsJson).Values.ToList();
        //}

        private async Task GetSummary()
        {
            var locationsJson = await httpClient.DownloadStringAsync("https://nzcovid19api.xerra.nz/casestats/json");

            AppSummary = new CovidSummary(CovidSummary.FromJson(locationsJson));
        }