You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
740 B
29 lines
740 B
namespace MyBlazorApp.Services
|
|
{
|
|
public class WeatherForecastService
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
|
|
public WeatherForecastService(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public async Task<IEnumerable<WeatherForecast>> GetForecastsAsync()
|
|
{
|
|
var res = await _httpClient.GetFromJsonAsync<IEnumerable<WeatherForecast>>("weatherforecast");
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public class WeatherForecast
|
|
{
|
|
public DateOnly Date { get; set; }
|
|
|
|
public int TemperatureC { get; set; }
|
|
|
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
|
|
|
public string? Summary { get; set; }
|
|
}
|
|
}
|
|
|