I am new to both .NET Core home somebody can guide me through this.
I need to make a request to this url and save the data into database: url: https://covid19.mathdro.id/api
JSON output looks like this:
{"confirmed":{"value":303001,"detail":"https://covid19.mathdro.id/api/confirmed"},"recovered":{"value":91669,"detail":"https://covid19.mathdro.id/api/recovered"},"deaths":{"value":12762,"detail":"https://covid19.mathdro.id/api/deaths"},"dailySummary":"https://covid19.mathdro.id/api/daily","dailyTimeSeries":{"pattern":"https://covid19.mathdro.id/api/daily/[dateString]","example":"https://covid19.mathdro.id/api/daily/2-14-2020"},"image":"https://covid19.mathdro.id/api/og","source":"https://github.com/mathdroid/covid19","countries":"https://covid19.mathdro.id/api/countries","countryDetail":{"pattern":"https://covid19.mathdro.id/api/countries/[country]","example":"https://covid19.mathdro.id/api/countries/USA"},"lastUpdate":"2020-03-21T20:13:21.000Z"}
Model: Totals
public class Total
{
[Key]
public int Id { get; set; }
[Column(TypeName = "int")]
[Required]
public string Confirmed { get; set; }
[Column(TypeName = "int")]
[Required]
public string Recovered { get; set; }
[Column(TypeName = "int")]
[Required]
public string Deaths { get; set; }
[Column(TypeName = "datetime2")]
[Required]
public string LastUpdated { get; set; }
}
My import model:
client.BaseAddress = new Uri("https://covid19.mathdro.id/api");
var response = await client.GetAsync($"");
response.EnsureSuccessStatusCode();
var stringResult = await response.Content.ReadAsStringAsync();
I am stuck from here and cant continue. How do I fetch the data, I need only: confirmed, recovered, deaths and lastUpdate
Pls. anybody help here...