Пример #1
0
        public async Task <bool> CreateAsync()
        {
            var casesList = new List <CovidTrackingApiViewModel>();

            string[] countries = { "Brazil", "Japan", "Netherlands", "Nigeria", "Australia", "World" };
            foreach (var country in countries)
            {
                if (!await _casesRepository.ExistData(country))
                {
                    var cases = await _covidTrackingService.GetByCountryAsync(country);

                    FormatValues(cases);
                    casesList.Add(cases);
                }
            }
            if (casesList.Count == 0)
            {
                Notify("Os registros já existem na base");
                return(false);
            }
            var models = _mapper.Map <List <Cases> >(casesList);

            _casesRepository.Add(models);

            return(await _casesRepository.UnitOfWork.Commit());
        }
Пример #2
0
        public async Task <IActionResult> GetByCountry(string country)
        {
            var content = await _covidTrackingService.GetByCountryAsync(country);

            return(CustomResponse(content));
        }