private async void SelectedData()
        {
            string regionName = Location[Region];

            if (Region > 1 && Region < 6)
            {
                ContinentData continent = await covidService.FindContinent(regionName);

                TodayCases  = continent.TodayCases;
                Cases       = continent.Cases;
                TodayDeaths = continent.TodayDeaths;
                Deaths      = continent.Deaths;
                Recovered   = continent.Recovered;
                Active      = continent.Active;
                Tests       = continent.Tests;
            }
            else if (Region > 6)
            {
                CountryData country = await covidService.FindCountry(regionName);

                TodayCases  = country.TodayCases;
                Cases       = country.Cases;
                TodayDeaths = country.TodayDeaths;
                Deaths      = country.Deaths;
                Recovered   = country.Recovered;
                Active      = country.Active;
                Tests       = country.Tests;
            }
            else
            {
                GetGlobalData();
            }
        }
Ejemplo n.º 2
0
        public async Task <ContinentData> FindContinent(string continent)
        {
            var res = await client.GetAsync($"https://corona.lmao.ninja/v2/continents/{continent}?yesterday&strict");

            var content = await res.Content.ReadAsStringAsync();

            ContinentData foundContinent = JsonConvert.DeserializeObject <ContinentData>(content);

            return(foundContinent);
        }
 public void Update(ContinentData entity)
 {
     using (WorldMapDBContext context = new WorldMapDBContext())
     {
         DbSet table = context.ContinentData;
         table.Attach(entity);
         context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }