File tree Expand file tree Collapse file tree 4 files changed +36
-28
lines changed Expand file tree Collapse file tree 4 files changed +36
-28
lines changed Original file line number Diff line number Diff line change 44 <TargetFramework >net8.0</TargetFramework >
55 <Nullable >enable</Nullable >
66 <ImplicitUsings >enable</ImplicitUsings >
7- <RuntimeIdentifiers >linux-x64</RuntimeIdentifiers >
8- <EnableSdkContainerDebugging >True</EnableSdkContainerDebugging >
9- <UserSecretsId >7b8931a0-bda7-4546-b99d-dc41f97af10e</UserSecretsId >
10- <DockerDefaultTargetOS >Linux</DockerDefaultTargetOS >
117 </PropertyGroup >
128
139 <ItemGroup >
1612 <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 6.4.0" />
1713 </ItemGroup >
1814
19- <ItemGroup >
20- <ContainerEnvironmentVariable Include =" ASPNETCORE_HTTPS_PORTS" >
21- <Value >8081</Value >
22- </ContainerEnvironmentVariable >
23- </ItemGroup >
2415
2516 <ItemGroup >
2617 <ProjectReference Include =" ..\ServiceDefaults\ServiceDefaults.csproj" />
Original file line number Diff line number Diff line change 66 <ImplicitUsings >enable</ImplicitUsings >
77 </PropertyGroup >
88
9- <ItemGroup >
10- <OpenApiReference Include =" OpenAPIs\swagger.json" CodeGenerator =" NSwagCSharp" Options =" /UseBaseUrl:false" ClassName =" NwsManager" >
11- <SourceUri >https://localhost:7032/swagger/v1/swagger.json</SourceUri >
12- </OpenApiReference >
13- </ItemGroup >
149
1510 <ItemGroup >
1611 <PackageReference Include =" Microsoft.AspNetCore.Components.QuickGrid" Version =" 8.0.6" />
1712 <PackageReference Include =" Microsoft.Extensions.ApiDescription.Client" Version =" 7.0.2" >
1813 <PrivateAssets >all</PrivateAssets >
1914 <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
2015 </PackageReference >
21- <PackageReference Include =" Newtonsoft.Json" Version =" 13.0.1" />
22- <PackageReference Include =" NSwag.ApiDescription.Client" Version =" 13.18.2" >
23- <PrivateAssets >all</PrivateAssets >
24- <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
25- </PackageReference >
2616 </ItemGroup >
2717
2818 <ItemGroup >
Original file line number Diff line number Diff line change 1+ using System . Text . Json ;
2+
3+ namespace MyWeatherHub ;
4+
5+ public class NwsManager ( HttpClient client )
6+ {
7+ readonly JsonSerializerOptions options = new ( )
8+ {
9+ PropertyNameCaseInsensitive = true
10+ } ;
11+
12+ public async Task < Zone [ ] > GetZonesAsync ( )
13+ {
14+ var response = await client . GetAsync ( "zones" ) ;
15+ response . EnsureSuccessStatusCode ( ) ;
16+
17+ var content = await response . Content . ReadAsStringAsync ( ) ;
18+ var zones = JsonSerializer . Deserialize < Zone [ ] > ( content , options ) ;
19+
20+ return zones ?? [ ] ;
21+ }
22+
23+ public async Task < Forecast [ ] > GetForecastByZoneAsync ( string zoneId )
24+ {
25+ var response = await client . GetAsync ( $ "forecast/{ zoneId } ") ;
26+ response . EnsureSuccessStatusCode ( ) ;
27+ var content = await response . Content . ReadAsStringAsync ( ) ;
28+ var forecast = JsonSerializer . Deserialize < Forecast [ ] > ( content , options ) ;
29+
30+ return forecast ?? [ ] ;
31+ }
32+ }
33+
34+ public record Zone ( string Key , string Name , string State ) ;
35+
36+ public record Forecast ( string Name , string DetailedForecast ) ;
Original file line number Diff line number Diff line change 44 <TargetFramework >net8.0</TargetFramework >
55 <Nullable >enable</Nullable >
66 <ImplicitUsings >enable</ImplicitUsings >
7- <RuntimeIdentifiers >linux-x64</RuntimeIdentifiers >
8- <EnableSdkContainerDebugging >True</EnableSdkContainerDebugging >
9- <UserSecretsId >7b8931a0-bda7-4546-b99d-dc41f97af10e</UserSecretsId >
10- <DockerDefaultTargetOS >Linux</DockerDefaultTargetOS >
117 </PropertyGroup >
128
139 <ItemGroup >
1410 <PackageReference Include =" Microsoft.AspNetCore.OpenApi" Version =" 8.0.6" />
1511 <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 6.4.0" />
1612 </ItemGroup >
1713
18- <ItemGroup >
19- <ContainerEnvironmentVariable Include =" ASPNETCORE_HTTPS_PORTS" >
20- <Value >8081</Value >
21- </ContainerEnvironmentVariable >
22- </ItemGroup >
2314
2415</Project >
You can’t perform that action at this time.
0 commit comments