From f8192482bfaa8d2e2c5e997c19740cc8b7135833 Mon Sep 17 00:00:00 2001 From: Maarten Zeeman Date: Sat, 14 Feb 2026 20:20:50 +0100 Subject: [PATCH] Added Aspire --- .../Lutra.API/Controllers/HealthController.cs | 14 +++++++++ Lutra/Lutra.API/Lutra.API.csproj | 6 ++-- Lutra/Lutra.AppHost/AppHost.cs | 13 +++++++++ Lutra/Lutra.AppHost/Lutra.AppHost.csproj | 22 ++++++++++++++ .../Properties/launchSettings.json | 29 +++++++++++++++++++ .../appsettings.Development.json | 8 +++++ Lutra/Lutra.AppHost/appsettings.json | 9 ++++++ .../Interfaces/ILutraDbContext.cs | 12 ++++++++ .../Lutra.Application.csproj | 9 ++++-- Lutra/Lutra.Domain/Class1.cs | 7 ----- Lutra/Lutra.Domain/Entities/BaseEntity.cs | 14 +++++++++ Lutra/Lutra.Domain/Entities/Supermarkt.cs | 9 ++++++ Lutra/Lutra.Domain/Entities/Verspakket.cs | 23 +++++++++++++++ Lutra/Lutra.Domain/Lutra.Domain.csproj | 2 +- Lutra/Lutra.Infrastructure/Class1.cs | 7 ----- .../Lutra.Infrastructure.Sql.csproj | 17 +++++++++++ .../Lutra.Infrastructure.csproj | 9 ------ Lutra/Lutra.Infrastructure/LutraDbContext.cs | 20 +++++++++++++ Lutra/Lutra.sln | 12 ++++++-- 19 files changed, 210 insertions(+), 32 deletions(-) create mode 100644 Lutra/Lutra.API/Controllers/HealthController.cs create mode 100644 Lutra/Lutra.AppHost/AppHost.cs create mode 100644 Lutra/Lutra.AppHost/Lutra.AppHost.csproj create mode 100644 Lutra/Lutra.AppHost/Properties/launchSettings.json create mode 100644 Lutra/Lutra.AppHost/appsettings.Development.json create mode 100644 Lutra/Lutra.AppHost/appsettings.json create mode 100644 Lutra/Lutra.Application/Interfaces/ILutraDbContext.cs delete mode 100644 Lutra/Lutra.Domain/Class1.cs create mode 100644 Lutra/Lutra.Domain/Entities/BaseEntity.cs create mode 100644 Lutra/Lutra.Domain/Entities/Supermarkt.cs create mode 100644 Lutra/Lutra.Domain/Entities/Verspakket.cs delete mode 100644 Lutra/Lutra.Infrastructure/Class1.cs create mode 100644 Lutra/Lutra.Infrastructure/Lutra.Infrastructure.Sql.csproj delete mode 100644 Lutra/Lutra.Infrastructure/Lutra.Infrastructure.csproj create mode 100644 Lutra/Lutra.Infrastructure/LutraDbContext.cs diff --git a/Lutra/Lutra.API/Controllers/HealthController.cs b/Lutra/Lutra.API/Controllers/HealthController.cs new file mode 100644 index 0000000..cf0ad4a --- /dev/null +++ b/Lutra/Lutra.API/Controllers/HealthController.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; + +namespace Lutra.API.Controllers; + +[ApiController] +[Route("health")] +public class HealthController : Controller +{ + public IActionResult Index() + { + return Ok(); + } +} diff --git a/Lutra/Lutra.API/Lutra.API.csproj b/Lutra/Lutra.API/Lutra.API.csproj index 7c062f6..4326340 100644 --- a/Lutra/Lutra.API/Lutra.API.csproj +++ b/Lutra/Lutra.API/Lutra.API.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable c9bd54b0-d347-4e93-bcea-ed5e98a71d5c @@ -9,8 +9,8 @@ - - + + diff --git a/Lutra/Lutra.AppHost/AppHost.cs b/Lutra/Lutra.AppHost/AppHost.cs new file mode 100644 index 0000000..6b85fe1 --- /dev/null +++ b/Lutra/Lutra.AppHost/AppHost.cs @@ -0,0 +1,13 @@ +var builder = DistributedApplication.CreateBuilder(args); + +var sql = builder.AddSqlServer("sql") + .WithLifetime(ContainerLifetime.Persistent); + +var db = sql.AddDatabase("database", "Lutra"); + +var apiService = builder.AddProject("apiservice") + .WithHttpHealthCheck("/health") + .WithReference(db) + .WaitFor(db); + +builder.Build().Run(); diff --git a/Lutra/Lutra.AppHost/Lutra.AppHost.csproj b/Lutra/Lutra.AppHost/Lutra.AppHost.csproj new file mode 100644 index 0000000..c64e76e --- /dev/null +++ b/Lutra/Lutra.AppHost/Lutra.AppHost.csproj @@ -0,0 +1,22 @@ + + + + + + Exe + net10.0 + enable + enable + cb3bf793-12ac-4e3d-9aeb-c2e3cb36a9fe + + + + + + + + + + + + diff --git a/Lutra/Lutra.AppHost/Properties/launchSettings.json b/Lutra/Lutra.AppHost/Properties/launchSettings.json new file mode 100644 index 0000000..fdb6106 --- /dev/null +++ b/Lutra/Lutra.AppHost/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:17126;http://localhost:15299", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21049", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22271" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15299", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19176", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20117" + } + } + } +} diff --git a/Lutra/Lutra.AppHost/appsettings.Development.json b/Lutra/Lutra.AppHost/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Lutra/Lutra.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Lutra/Lutra.AppHost/appsettings.json b/Lutra/Lutra.AppHost/appsettings.json new file mode 100644 index 0000000..31c092a --- /dev/null +++ b/Lutra/Lutra.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/Lutra/Lutra.Application/Interfaces/ILutraDbContext.cs b/Lutra/Lutra.Application/Interfaces/ILutraDbContext.cs new file mode 100644 index 0000000..1e5a811 --- /dev/null +++ b/Lutra/Lutra.Application/Interfaces/ILutraDbContext.cs @@ -0,0 +1,12 @@ +using Lutra.Domain.Entities; +using Microsoft.EntityFrameworkCore; +namespace Lutra.Application.Interfaces; + +public interface ILutraDbContext +{ + DbSet Supermarkten { get; } + + DbSet Verspaketten { get; } + + Task SaveChangesAsync(CancellationToken cancellationToken); +} diff --git a/Lutra/Lutra.Application/Lutra.Application.csproj b/Lutra/Lutra.Application/Lutra.Application.csproj index e8c4d99..e455dca 100644 --- a/Lutra/Lutra.Application/Lutra.Application.csproj +++ b/Lutra/Lutra.Application/Lutra.Application.csproj @@ -1,13 +1,18 @@  - net9.0 + net10.0 enable enable - + + + + + + diff --git a/Lutra/Lutra.Domain/Class1.cs b/Lutra/Lutra.Domain/Class1.cs deleted file mode 100644 index 7cfe7a4..0000000 --- a/Lutra/Lutra.Domain/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Lutra.Domain -{ - public class Class1 - { - - } -} diff --git a/Lutra/Lutra.Domain/Entities/BaseEntity.cs b/Lutra/Lutra.Domain/Entities/BaseEntity.cs new file mode 100644 index 0000000..222e25c --- /dev/null +++ b/Lutra/Lutra.Domain/Entities/BaseEntity.cs @@ -0,0 +1,14 @@ +namespace Lutra.Domain.Entities; + +public abstract class BaseEntity +{ + public Guid Id { get; set; } + + public DateTime CreatedAt { get; set; } + + public DateTime ModifiedAt { get; set; } + + public DateTime? DeletedAt { get; set; } + + public bool IsDeleted => DeletedAt.HasValue; +} diff --git a/Lutra/Lutra.Domain/Entities/Supermarkt.cs b/Lutra/Lutra.Domain/Entities/Supermarkt.cs new file mode 100644 index 0000000..08f0fa0 --- /dev/null +++ b/Lutra/Lutra.Domain/Entities/Supermarkt.cs @@ -0,0 +1,9 @@ +using System.ComponentModel.DataAnnotations; + +namespace Lutra.Domain.Entities; + +public class Supermarkt : BaseEntity +{ + [MaxLength(50)] + public required string Naam { get; set; } +} diff --git a/Lutra/Lutra.Domain/Entities/Verspakket.cs b/Lutra/Lutra.Domain/Entities/Verspakket.cs new file mode 100644 index 0000000..4146c6c --- /dev/null +++ b/Lutra/Lutra.Domain/Entities/Verspakket.cs @@ -0,0 +1,23 @@ +using System.ComponentModel.DataAnnotations; + +namespace Lutra.Domain.Entities; + +public class Verspakket : BaseEntity +{ + [MaxLength(50)] + public required string Naam { get; set; } + + [Range(1, 100)] + public int Cijfer { get; set; } + + [MaxLength(255)] + public string? Opmerking { get; set; } + + [Range(1, 10)] + public int AantalPersonen { get; set; } + + public required Guid SupermarktId { get; set; } + + public required virtual Supermarkt Supermarkt { get; set; } +} + diff --git a/Lutra/Lutra.Domain/Lutra.Domain.csproj b/Lutra/Lutra.Domain/Lutra.Domain.csproj index 125f4c9..b760144 100644 --- a/Lutra/Lutra.Domain/Lutra.Domain.csproj +++ b/Lutra/Lutra.Domain/Lutra.Domain.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable diff --git a/Lutra/Lutra.Infrastructure/Class1.cs b/Lutra/Lutra.Infrastructure/Class1.cs deleted file mode 100644 index 01554e2..0000000 --- a/Lutra/Lutra.Infrastructure/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Lutra.Infrastructure -{ - public class Class1 - { - - } -} diff --git a/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.Sql.csproj b/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.Sql.csproj new file mode 100644 index 0000000..abe3c25 --- /dev/null +++ b/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.Sql.csproj @@ -0,0 +1,17 @@ + + + + net10.0 + enable + enable + + + + + + + + + + + diff --git a/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.csproj b/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.csproj deleted file mode 100644 index 125f4c9..0000000 --- a/Lutra/Lutra.Infrastructure/Lutra.Infrastructure.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net9.0 - enable - enable - - - diff --git a/Lutra/Lutra.Infrastructure/LutraDbContext.cs b/Lutra/Lutra.Infrastructure/LutraDbContext.cs new file mode 100644 index 0000000..408864d --- /dev/null +++ b/Lutra/Lutra.Infrastructure/LutraDbContext.cs @@ -0,0 +1,20 @@ +using Lutra.Application.Interfaces; +using Lutra.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lutra.Infrastructure.Sql; + +public class LutraDbContext : ILutraDbContext +{ + public DbSet Supermarkten => throw new NotImplementedException(); + + public DbSet Verspaketten => throw new NotImplementedException(); + + public Task SaveChangesAsync(CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } +} diff --git a/Lutra/Lutra.sln b/Lutra/Lutra.sln index 7739c30..c6fb1c1 100644 --- a/Lutra/Lutra.sln +++ b/Lutra/Lutra.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36310.24 +# Visual Studio Version 18 +VisualStudioVersion = 18.3.11222.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.API", "Lutra.API\Lutra.API.csproj", "{22B74CFE-E9D0-42F3-96E3-818D014E1A2E}" EndProject @@ -9,7 +9,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.Application", "Lutra. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.Domain", "Lutra.Domain\Lutra.Domain.csproj", "{DACBC33C-A76A-483A-8535-AA62D33D4977}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.Infrastructure", "Lutra.Infrastructure\Lutra.Infrastructure.csproj", "{0D9E0DD9-E914-483F-8046-8A57B510E984}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.Infrastructure.Sql", "Lutra.Infrastructure\Lutra.Infrastructure.Sql.csproj", "{0D9E0DD9-E914-483F-8046-8A57B510E984}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lutra.AppHost", "Lutra.AppHost\Lutra.AppHost.csproj", "{B9B41350-EB18-4564-81AB-C16F3E5A0CBB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,6 +35,10 @@ Global {0D9E0DD9-E914-483F-8046-8A57B510E984}.Debug|Any CPU.Build.0 = Debug|Any CPU {0D9E0DD9-E914-483F-8046-8A57B510E984}.Release|Any CPU.ActiveCfg = Release|Any CPU {0D9E0DD9-E914-483F-8046-8A57B510E984}.Release|Any CPU.Build.0 = Release|Any CPU + {B9B41350-EB18-4564-81AB-C16F3E5A0CBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9B41350-EB18-4564-81AB-C16F3E5A0CBB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9B41350-EB18-4564-81AB-C16F3E5A0CBB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9B41350-EB18-4564-81AB-C16F3E5A0CBB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE