public static async Task <JsonReports> getReportsByRegion(string region) { var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri($"https://covid-19-statistics.p.rapidapi.com/reports?iso={region}"), Headers = { { "x-rapidapi-key", "1b70fb959dmsh9f1b1131f7abdecp1eb3a2jsne8c1b7266ac5" }, { "x-rapidapi-host", "covid-19-statistics.p.rapidapi.com" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); JObject json = JObject.Parse(body); JsonReports resultReports = json.ToObject <JsonReports>(); return(resultReports); } }
public void GenerateJsonReports() { string directoryPath = Constants.JsonReportsPath; var reports = JsonReports.GenerateReports(directoryPath); JsonReports.SeedReportsToMySQL(reports); }
public void GenerateJsonReports() { string directoryPath = Constants.JsonReportsPath; var reports = JsonReports.GenerateReports(directoryPath); textWriter.WriteLine("JSON Reports created!"); JsonReports.SeedReportsToMySQL(reports); textWriter.WriteLine("Reports Updated to MySQL database!"); }
public async Task <ActionResult> IndexByProvince() { string iso = RouteData.Values["id"].ToString(); JsonRegions dataRegions = await CovidAPI.getRegion(); JsonReports dataReports = await CovidAPI.getReportsByProvince(iso); List <ReportsModels> dataReportsShown = new List <ReportsModels>(); dataReportsShown = dataReports.data; dataReportsShown = dataReportsShown.OrderByDescending(x => Convert.ToInt32(x.confirmed)).ToList <ReportsModels>(); //dataReportsShown = from x in dataReports.data // orderby x.active descending // select x; ViewBag.regions = dataRegions.data.OrderBy(x => x.name).ToList <RegionsModels>(); ViewBag.reports = dataReportsShown.Take(10); ViewBag.iso = iso; return(View()); }
// GET: CovidAPI public async Task <ActionResult> Index() { //ViewBag.data = getReportsByRegion(); //ViewBag.provinces = getReportsByProvince(); JsonRegions dataRegions = await CovidAPI.getRegion(); JsonReports dataReports = await CovidAPI.getReports(); List <ReportsModels> dataReportsShown = new List <ReportsModels>(); dataReportsShown = dataReports.data; dataReportsShown = dataReportsShown.OrderByDescending(x => Convert.ToInt32(x.confirmed)).ToList <ReportsModels>(); //dataReportsShown = from x in dataReports.data // orderby x.active descending // select x; ViewBag.regions = dataRegions.data.OrderBy(x => x.name).ToList <RegionsModels>(); ViewBag.reports = dataReportsShown.Take(10); return(View()); }