示例#1
0
        private async Task LoadDataCountry()
        {
            var service = new CasesWorldService();
            var cases   = await service.GetCasesFromBrasil();

            if (cases != null && cases.data != null)
            {
                var data = cases.data;

                Location       = "Brasil";
                Recovered      = string.Format("{0:N0}", data.latest_data.recovered);
                NumberCases    = string.Format("{0:N0}", data.latest_data.confirmed);
                NumberDeaths   = string.Format("{0:N0}", data.latest_data.deaths);
                Critical       = string.Format("{0:N0}", data.latest_data.critical);
                Population     = string.Format("{0:N0}", data.population);
                ConfirmedToday = string.Format("{0:N0}", data.today.confirmed);
                DeathsToday    = string.Format("{0:N0}", data.today.deaths);
                DeathsRate     = string.Format("{0:N1}", (data.latest_data.calculated.death_rate)) + "%";
                DateUpdate     = data.updated_at.ToString("dd/MM/yyyy");

                if (cases.data.timeline != null && cases.data.timeline.Count > 0)
                {
                    var timeline = (from line in cases.data.timeline
                                    where line.date >= DateTime.Now.AddDays(-15)
                                    //&& line.date < DateTime.Now.Date
                                    orderby line.date ascending
                                    select line).ToList();

                    if (timeline != null && timeline.Count > 0)
                    {
                        LoadChartCasesAccumulated(timeline);
                        LoadChartDeathsAccumulated(timeline);
                        LoadChartNewCases(timeline);
                        LoadChartNewDeaths(timeline);
                    }
                }
            }
        }
示例#2
0
        private async void LoadDataCountry(ItemSearchListVO item)
        {
            aciLoading.IsRunning = true;
            aciLoading.IsVisible = true;
            stlGeral.IsVisible   = false;
            try
            {
                var service = new CasesWorldService();
                var cases   = await service.GetCasesFromCountry(item.Code);

                if (cases.data.timeline != null && cases.data.timeline.Count > 0)
                {
                    var timeline = (from line in cases.data.timeline
                                    where line.date >= DateTime.Now.AddDays(-15)
                                    //&& line.date < DateTime.Now.Date
                                    orderby line.date ascending
                                    select line).ToList();

                    if (timeline != null && timeline.Count > 0)
                    {
                        LoadChartCasesAccumulated(timeline);
                        LoadChartDeathsAccumulated(timeline);
                        LoadChartNewCases(timeline);
                        LoadChartNewDeaths(timeline);
                    }
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Toast(ex.Message, TimeSpan.FromSeconds(5));
            }
            finally
            {
                aciLoading.IsRunning = false;
                aciLoading.IsVisible = false;
                stlGeral.IsVisible   = true;
            }
        }
示例#3
0
        private async Task LoadDataWorld()
        {
            var casesService = new CasesWorldService();
            var cases        = await casesService.GetCasesFromWorld();

            if (cases != null)
            {
                var countries = CountriesOfWorld.getCountriesOfWorld();

                var lista = (from pais in cases.data
                             orderby(pais.latest_data.confirmed == null ? 0 : (long)pais.latest_data.confirmed) descending
                             select new ItemSearchListVO
                {
                    Code = pais.code,
                    Name = countries.Where(F => F.NameEn == pais.name.ToUpper().Trim()).Any() ? countries.Where(F => F.NameEn == pais.name.ToUpper().Trim()).FirstOrDefault().NamePT.ToUpper().Trim() : pais.name.ToUpper().ToUpper(),
                    Confirmed = string.Format("{0:N0}", (pais.latest_data.confirmed == null ? 0 : (long)pais.latest_data.confirmed)),
                    Recovered = string.Format("{0:N0}", (pais.latest_data.recovered == null ? 0 : (long)pais.latest_data.recovered)),
                    Deaths = string.Format("{0:N0}", (pais.latest_data.deaths == null ? 0 : (long)pais.latest_data.deaths)),
                    DeathRate = string.Format("{0:N1}", (pais.latest_data.calculated.death_rate == null ? 0 : ((decimal)pais.latest_data.calculated.death_rate))) + "%",
                    ConfirmedToday = string.Format("{0:N0}", (pais.today.confirmed == null ? 0 : (long)pais.today.confirmed)),
                    DeathsToday = string.Format("{0:N0}", (pais.today.deaths == null ? 0 : (long)pais.today.deaths))
                }).ToList();

                if (AtivarTraducao)
                {
                    //Traduz até 2 milhões de caracteres por mês (modo gratuito)
                    var translationService = new TextTranslationService(new AuthenticationService(TranslationConstants.TextTranslatorApiKey));
                    foreach (var item in lista)
                    {
                        item.Name = await translationService.TranslateTextAsync(item.Name);
                    }
                }

                List = lista;
            }
        }