Skip to content

Commit 4f0625b

Browse files
authored
Merge pull request #271 from dagstuan/dotnet9
Upgrade to .net 9
2 parents 2848d5c + bc2e61a commit 4f0625b

12 files changed

+53
-55
lines changed

SkredvarselGarminWeb/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0.401-1-bookworm-slim AS base
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0.100-bookworm-slim AS base
22
RUN apt-get update
33
RUN apt-get install -y ca-certificates curl gnupg
44
RUN mkdir -p /etc/apt/keyrings
@@ -16,7 +16,7 @@ COPY . .
1616
RUN dotnet test
1717
RUN dotnet publish SkredvarselGarminWeb -c Release -o publish
1818

19-
FROM mcr.microsoft.com/dotnet/sdk:8.0.401-1-bookworm-slim
19+
FROM mcr.microsoft.com/dotnet/sdk:9.0.100-bookworm-slim
2020
EXPOSE 8080
2121
WORKDIR /app
2222
COPY --from=builder /app/publish ./

SkredvarselGarminWeb/SkredvarselGarminWeb.Tests/SkredvarselGarminWeb.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -10,9 +10,9 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="AutoFixture" Version="4.18.1" />
13-
<PackageReference Include="FluentAssertions" Version="6.12.2" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
13+
<PackageReference Include="FluentAssertions" Version="7.0.0" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1616
<PackageReference Include="NSubstitute" Version="5.3.0" />
1717
<PackageReference Include="xunit" Version="2.9.2" />
1818
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">

SkredvarselGarminWeb/SkredvarselGarminWeb/Endpoints/ForecastAreaEndpointsRouteBuilderExtensions.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ public static void MapForecastAreaEndpoints(this IEndpointRouteBuilder app)
2626

2727
var geometry = serializer.Deserialize<FeatureCollection>(jsonReader);
2828

29-
if (geometry == null)
30-
{
31-
return Results.BadRequest("Invalid GeoJSON");
32-
}
33-
34-
return Results.Ok(forecastAreaService.ReplaceForecastAreas(geometry));
29+
return geometry == null ?
30+
Results.BadRequest("Invalid GeoJSON") :
31+
Results.Ok(forecastAreaService.ReplaceForecastAreas(geometry));
3532
}).DisableAntiforgery().RequireAuthorization("Admin");
3633
}
3734
}

SkredvarselGarminWeb/SkredvarselGarminWeb/Endpoints/StripeSubscriptionEndpointsRouteBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static void MapStripeSubscriptionEndpoints(this IEndpointRouteBuilder app
4242
SuccessUrl = $"{baseUrl}/stripe-subscribe-callback?session_id={{CHECKOUT_SESSION_ID}}",
4343
CancelUrl = $"{baseUrl}/account",
4444
Mode = "subscription",
45-
CustomerEmail = user.StripeCustomerId.IsNullOrEmpty() ? user.Email : null,
45+
CustomerEmail = user.StripeCustomerId is { Length: > 0 } ? user.Email : null,
4646
Customer = user.StripeCustomerId,
4747
ClientReferenceId = user.Id,
4848
LineItems = [

SkredvarselGarminWeb/SkredvarselGarminWeb/Endpoints/SubscriptionEndpointsRouteBuilderExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,14 @@ public static void MapSubscriptionApiEndpoints(this IEndpointRouteBuilder app)
7171
var activeStripeSubscription = stripeSubscriptionsInDb
7272
.FirstOrDefault(ss => ss.Status == Entities.StripeSubscriptionStatus.ACTIVE
7373
|| ss.Status == Entities.StripeSubscriptionStatus.UNSUBSCRIBED);
74-
if (activeStripeSubscription != null)
75-
{
76-
return Results.Ok(new SubscriptionResponse
74+
return activeStripeSubscription != null
75+
? Results.Ok(new SubscriptionResponse
7776
{
7877
SubscriptionType = SubscriptionType.Stripe,
7978
StripeSubscriptionStatus = activeStripeSubscription.Status,
8079
NextChargeDate = activeStripeSubscription.NextChargeDate,
81-
});
82-
}
83-
84-
return Results.NoContent();
80+
})
81+
: Results.NoContent();
8582
}).RequireAuthorization();
8683
}
8784
}

SkredvarselGarminWeb/SkredvarselGarminWeb/Endpoints/VippsSubscriptionEndpointsRouteBuilderExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,15 @@ public static void MapVippsSubscriptionEndpoints(this IEndpointRouteBuilder app)
145145
vippsAgreement = await vippsApiClient.GetAgreement(agreement.Id);
146146
}
147147

148-
if (vippsAgreement.Status == VippsAgreementStatus.Stopped ||
149-
vippsAgreement.Status == VippsAgreementStatus.Expired)
148+
if (vippsAgreement.Status is
149+
VippsAgreementStatus.Stopped or
150+
VippsAgreementStatus.Expired)
150151
{
151152
dbContext.Remove(agreement);
152153
}
153154
else if (vippsAgreement.Status == VippsAgreementStatus.Active)
154155
{
155-
if (string.IsNullOrEmpty(agreement.UserId))
156+
if (agreement.UserId is { Length: > 0 })
156157
{
157158
var signedInUser = dbContext.GetUserOrNull(ctx.User);
158159
if (signedInUser != null)

SkredvarselGarminWeb/SkredvarselGarminWeb/Endpoints/WatchApiRouteBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static void MapWatchApiEndpoints(this IEndpointRouteBuilder app)
7474
[FromHeader(Name = "Authorization")] string authorizationHeader,
7575
IGarminAuthenticationService garminAuthenticationService) =>
7676
{
77-
if (authorizationHeader.IsNullOrEmpty())
77+
if (authorizationHeader is { Length: > 0 })
7878
{
7979
return Results.Unauthorized();
8080
}

SkredvarselGarminWeb/SkredvarselGarminWeb/Frontend/vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
2222

2323
// https://vitejs.dev/config/
2424
export default defineConfig(async () => {
25-
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
25+
if (
26+
process.env.NODE_ENV !== "production" &&
27+
(!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath))
28+
) {
2629
// Wait for the certificate to be generated
2730
await new Promise<void>((resolve) => {
2831
spawn(

SkredvarselGarminWeb/SkredvarselGarminWeb/Hangfire/HangfireService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public async Task RemoveStalePendingAgreements()
4747
{
4848
var vippsAgreement = await vippsApiClient.GetAgreement(agreement.Id);
4949

50-
if (vippsAgreement.Status == VippsAgreementStatus.Expired ||
51-
vippsAgreement.Status == VippsAgreementStatus.Stopped)
50+
if (vippsAgreement.Status is
51+
VippsAgreementStatus.Expired or
52+
VippsAgreementStatus.Stopped)
5253
{
5354
logger.LogInformation("Deleting stale agreement {agreementId} since it was expired in Vipps.", agreement.Id);
5455
dbContext.Remove(agreement);

SkredvarselGarminWeb/SkredvarselGarminWeb/Services/StripeService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ public void HandleWebhook(Event stripeEvent)
3434
StoreNewSubscriptionIfNotExists(session);
3535
}
3636
else if (
37-
stripeEvent.Type == EventTypes.CustomerSubscriptionUpdated ||
38-
stripeEvent.Type == EventTypes.CustomerSubscriptionDeleted ||
39-
stripeEvent.Type == EventTypes.CustomerSubscriptionPaused ||
40-
stripeEvent.Type == EventTypes.CustomerSubscriptionResumed)
37+
stripeEvent.Type is
38+
EventTypes.CustomerSubscriptionUpdated or
39+
EventTypes.CustomerSubscriptionDeleted or
40+
EventTypes.CustomerSubscriptionPaused or
41+
EventTypes.CustomerSubscriptionResumed)
4142
{
4243
var subscription = (Subscription)stripeEvent.Data.Object;
4344
HandleSubscriptionUpdated(subscription);

0 commit comments

Comments
 (0)