Added Aspire

This commit is contained in:
Maarten Zeeman
2026-02-14 20:20:50 +01:00
parent bf8c71c504
commit f8192482bf
19 changed files with 210 additions and 32 deletions

View File

@@ -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();
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>c9bd54b0-d347-4e93-bcea-ed5e98a71d5c</UserSecretsId>
@@ -9,8 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cortex.Mediator" Version="1.7.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.7" />
<PackageReference Include="Cortex.Mediator" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
</ItemGroup>

View File

@@ -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<Projects.Lutra_API>("apiservice")
.WithHttpHealthCheck("/health")
.WithReference(db)
.WaitFor(db);
builder.Build().Run();

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>cb3bf793-12ac-4e3d-9aeb-c2e3cb36a9fe</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.SqlServer" Version="13.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lutra.API\Lutra.API.csproj" />
</ItemGroup>
</Project>

View File

@@ -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"
}
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}

View File

@@ -0,0 +1,12 @@
using Lutra.Domain.Entities;
using Microsoft.EntityFrameworkCore;
namespace Lutra.Application.Interfaces;
public interface ILutraDbContext
{
DbSet<Supermarkt> Supermarkten { get; }
DbSet<Verspakket> Verspaketten { get; }
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
}

View File

@@ -1,13 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cortex.Mediator" Version="1.7.0" />
<PackageReference Include="Cortex.Mediator" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lutra.Domain\Lutra.Domain.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,7 +0,0 @@
namespace Lutra.Domain
{
public class Class1
{
}
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
using System.ComponentModel.DataAnnotations;
namespace Lutra.Domain.Entities;
public class Supermarkt : BaseEntity
{
[MaxLength(50)]
public required string Naam { get; set; }
}

View File

@@ -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; }
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

View File

@@ -1,7 +0,0 @@
namespace Lutra.Infrastructure
{
public class Class1
{
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lutra.Application\Lutra.Application.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,9 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -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<Supermarkt> Supermarkten => throw new NotImplementedException();
public DbSet<Verspakket> Verspaketten => throw new NotImplementedException();
public Task<int> SaveChangesAsync(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}

View File

@@ -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