diff --git a/complete/Api/Api.csproj b/complete/Api/Api.csproj index 49a7446..ab6cf95 100644 --- a/complete/Api/Api.csproj +++ b/complete/Api/Api.csproj @@ -4,10 +4,6 @@ net8.0 enable enable - linux-x64 - True - 7b8931a0-bda7-4546-b99d-dc41f97af10e - Linux @@ -16,11 +12,6 @@ - - - 8081 - - diff --git a/complete/MyWeatherHub/MyWeatherHub.csproj b/complete/MyWeatherHub/MyWeatherHub.csproj index 5c5f8eb..350bdc3 100644 --- a/complete/MyWeatherHub/MyWeatherHub.csproj +++ b/complete/MyWeatherHub/MyWeatherHub.csproj @@ -6,11 +6,6 @@ enable - - - https://localhost:7032/swagger/v1/swagger.json - - @@ -18,11 +13,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/complete/MyWeatherHub/NwsManager.cs b/complete/MyWeatherHub/NwsManager.cs new file mode 100644 index 0000000..05fc894 --- /dev/null +++ b/complete/MyWeatherHub/NwsManager.cs @@ -0,0 +1,36 @@ +using System.Text.Json; + +namespace MyWeatherHub; + +public class NwsManager(HttpClient client) +{ + readonly JsonSerializerOptions options = new() + { + PropertyNameCaseInsensitive = true + }; + + public async Task GetZonesAsync() + { + var response = await client.GetAsync("zones"); + response.EnsureSuccessStatusCode(); + + var content = await response.Content.ReadAsStringAsync(); + var zones = JsonSerializer.Deserialize(content, options); + + return zones ?? []; + } + + public async Task GetForecastByZoneAsync(string zoneId) + { + var response = await client.GetAsync($"forecast/{zoneId}"); + response.EnsureSuccessStatusCode(); + var content = await response.Content.ReadAsStringAsync(); + var forecast = JsonSerializer.Deserialize(content, options); + + return forecast ?? []; + } +} + +public record Zone(string Key, string Name, string State); + +public record Forecast(string Name, string DetailedForecast); \ No newline at end of file diff --git a/start-with-api/Api/Api.csproj b/start-with-api/Api/Api.csproj index 9147f34..5459f9e 100644 --- a/start-with-api/Api/Api.csproj +++ b/start-with-api/Api/Api.csproj @@ -4,10 +4,6 @@ net8.0 enable enable - linux-x64 - True - 7b8931a0-bda7-4546-b99d-dc41f97af10e - Linux @@ -15,10 +11,5 @@ - - - 8081 - -