示例#1
0
        public async void OnAppearing()
        {
            try
            {
                var current = Connectivity.NetworkAccess;

                if (current == NetworkAccess.Internet)
                {
                    // Connection to internet is available
                    var stats = await StatsGenerator.GetStatsAsync();

                    Countrydata = stats;
                    await _pageDialogService.DisplayAlertAsync("Welcome!", "Information on covid-19 in South Africa", "ok");
                }
            }
            catch (Exception)
            {
                var current = Connectivity.NetworkAccess;

                if (current != NetworkAccess.Internet)
                {
                    await _pageDialogService.DisplayAlertAsync("Unexpected Error", "No Interent access", "cancel", "ok");
                }
            }
        }
示例#2
0
        static async Task Main(string[] args)
        {
            StatGenerator statGenerator = new StatGenerator();

            InformationHere informationHere = await StatGenerator.GetStatAsync();

            Console.WriteLine(informationHere.total_cases);

            //Console.WriteLine($"{statGenerator.ToString()}");
        }
示例#3
0
        public static async Task <InformationHere> GetStatsAsync()
        {
            HttpClient httpClient = new HttpClient();
            string     news       = await httpClient.GetStringAsync("https://coronavirus-19-api.herokuapp.com/countries/South%20Africa");



            Stats getter = JsonConvert.DeserializeObject <Stats>(news);


            InformationHere statInfo = new InformationHere()
            {
                cases      = getter.cases,
                active     = getter.active,
                recovered  = getter.recovered,
                deaths     = getter.deaths,
                todayCases = getter.todayCases,
            };

            return(statInfo);
        }