diff --git a/.gitignore b/.gitignore index 0bb609c..827c760 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,486 @@ -# .NET -dotnet/**/bin/ -dotnet/**/obj/ -dotnet/**/*.user -dotnet/**/*.vs/ -dotnet/**/.vs/ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` -# React/Node -react/node_modules/ -react/dist/ -react/.env -react/.env.local -react/.env.*.local +# dotenv files +.env -# IDE -.idea/ -.vscode/ +# User-specific files +*.rsuser *.suo -*.ntvs* -*.njsproj +*.user +*.userosscache *.sln.docstates -# OS -.DS_Store -Thumbs.db +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs -# Logs +# Mono auto generated files +mono_crash.* + +# Build results +**/bin/ +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +bin\\[Dd]ebug/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + + + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj *.log -npm-debug.log* +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc -# Claude Code plans -.claude/ +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..a1b2f8b --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3.9" + +services: + postgres: + image: postgres:18 + container_name: postgres + restart: unless-stopped + environment: + POSTGRES_DB: aips_db + POSTGRES_USER: user + POSTGRES_PASSWORD: secret + ports: + - "5432:5432" + volumes: + - pgdata:/var/lib/postgresql + +volumes: + pgdata: \ No newline at end of file diff --git a/dotnet/.gitignore b/dotnet/.gitignore deleted file mode 100644 index d8ac706..0000000 --- a/dotnet/.gitignore +++ /dev/null @@ -1,77 +0,0 @@ -# Environment variables with secrets -.env - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio cache/options directory -.vs/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# NuGet Packages -*.nupkg -*.snupkg -**/packages/* -!**/packages/build/ -*.nuget.props -*.nuget.targets - -# Docker -**/.dockerignore diff --git a/dotnet/AipsCore/AipsCore.csproj b/dotnet/AipsCore/AipsCore.csproj index 33bf3dd..0124700 100644 --- a/dotnet/AipsCore/AipsCore.csproj +++ b/dotnet/AipsCore/AipsCore.csproj @@ -8,6 +8,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommand.cs b/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommand.cs index 50c2786..3276be2 100644 --- a/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommand.cs +++ b/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommand.cs @@ -3,4 +3,4 @@ using AipsCore.Domain.Models.User.ValueObjects; namespace AipsCore.Application.Models.User.Command.CreateUser; -public record CreateUserCommand(string Username, string Email) : ICommand, ICommand; \ No newline at end of file +public record CreateUserCommand(string Username, string Email) : ICommand; \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommandHandler.cs b/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommandHandler.cs index f8755af..84b33fa 100644 --- a/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommandHandler.cs +++ b/dotnet/AipsCore/Application/Models/User/Command/CreateUser/CreateUserCommandHandler.cs @@ -1,10 +1,11 @@ using AipsCore.Application.Abstract.Command; using AipsCore.Domain.Abstract; using AipsCore.Domain.Models.User.External; +using AipsCore.Domain.Models.User.ValueObjects; namespace AipsCore.Application.Models.User.Command.CreateUser; -public class CreateUserCommandHandler : ICommandHandler +public class CreateUserCommandHandler : ICommandHandler { private readonly IUserRepository _userRepository; private readonly IUnitOfWork _unitOfWork; @@ -15,11 +16,13 @@ public class CreateUserCommandHandler : ICommandHandler _unitOfWork = unitOfWork; } - public async Task Handle(CreateUserCommand command, CancellationToken cancellationToken = default) + public async Task Handle(CreateUserCommand command, CancellationToken cancellationToken = default) { var user = Domain.Models.User.User.Create(command.Email, command.Username); await _userRepository.Save(user, cancellationToken); await _unitOfWork.SaveChangesAsync(cancellationToken); + + return user.Id; } } \ No newline at end of file diff --git a/dotnet/AipsCore/Infrastructure/DI/AipsRegistrationExtensions.cs b/dotnet/AipsCore/Infrastructure/DI/AipsRegistrationExtensions.cs index cc85caf..7c7e515 100644 --- a/dotnet/AipsCore/Infrastructure/DI/AipsRegistrationExtensions.cs +++ b/dotnet/AipsCore/Infrastructure/DI/AipsRegistrationExtensions.cs @@ -1,5 +1,8 @@ using AipsCore.Application.Abstract; +using AipsCore.Application.Abstract.Command; using AipsCore.Application.Common.Dispatcher; +using AipsCore.Application.Models.User.Command.CreateUser; +using AipsCore.Domain.Models.User.ValueObjects; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -10,7 +13,7 @@ public static class AipsRegistrationExtensions public static IServiceCollection AddAips(this IServiceCollection services, IConfiguration configuration) { services.AddHandlersFromAssembly(typeof(Dispatcher).Assembly); - services.AddSingleton(); + services.AddTransient(); services.AddPersistence(configuration); diff --git a/dotnet/AipsCore/Infrastructure/DI/HandlerRegistrationExtensions.cs b/dotnet/AipsCore/Infrastructure/DI/HandlerRegistrationExtensions.cs index 21caee5..f118921 100644 --- a/dotnet/AipsCore/Infrastructure/DI/HandlerRegistrationExtensions.cs +++ b/dotnet/AipsCore/Infrastructure/DI/HandlerRegistrationExtensions.cs @@ -33,7 +33,7 @@ public static class HandlerRegistrationExtensions if (!handlerInterfaces.Contains(genericDef)) continue; - services.AddScoped(@interface, type); + services.AddTransient(@interface, type); } } diff --git a/dotnet/AipsCore/Infrastructure/DI/PersistenceRegistrationExtensions.cs b/dotnet/AipsCore/Infrastructure/DI/PersistenceRegistrationExtensions.cs index 937df21..908959f 100644 --- a/dotnet/AipsCore/Infrastructure/DI/PersistenceRegistrationExtensions.cs +++ b/dotnet/AipsCore/Infrastructure/DI/PersistenceRegistrationExtensions.cs @@ -1,5 +1,8 @@ +using AipsCore.Domain.Abstract; +using AipsCore.Domain.Models.User.External; using AipsCore.Infrastructure.DI.Configuration; using AipsCore.Infrastructure.Persistence.Db; +using AipsCore.Infrastructure.Persistence.User; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -17,6 +20,9 @@ public static class PersistenceRegistrationExtensions npgsql.MigrationsAssembly(typeof(AipsDbContext).Assembly.FullName); }); }); + + services.AddTransient(); + services.AddTransient(); return services; } diff --git a/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs index 500e317..0e95553 100644 --- a/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs @@ -5,4 +5,10 @@ namespace AipsCore.Infrastructure.Persistence.Db; public class AipsDbContext : DbContext { public DbSet Users { get; set; } + + public AipsDbContext(DbContextOptions options) + : base(options) + { + + } } \ No newline at end of file diff --git a/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.Designer.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.Designer.cs new file mode 100644 index 0000000..0f86966 --- /dev/null +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.Designer.cs @@ -0,0 +1,51 @@ +// +using System; +using AipsCore.Infrastructure.Persistence.Db; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AipsCore.Infrastructure.Persistence.Db.Migrations +{ + [DbContext(typeof(AipsDbContext))] + [Migration("20260205205236_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AipsCore.Infrastructure.Persistence.User.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.cs new file mode 100644 index 0000000..68c4d24 --- /dev/null +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/20260205205236_Init.cs @@ -0,0 +1,35 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AipsCore.Infrastructure.Persistence.Db.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Username = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + Email = table.Column(type: "character varying(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/AipsDbContextModelSnapshot.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/AipsDbContextModelSnapshot.cs new file mode 100644 index 0000000..fa2c82a --- /dev/null +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/Migrations/AipsDbContextModelSnapshot.cs @@ -0,0 +1,48 @@ +// +using System; +using AipsCore.Infrastructure.Persistence.Db; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace AipsCore.Infrastructure.Persistence.Db.Migrations +{ + [DbContext(typeof(AipsDbContext))] + partial class AipsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("AipsCore.Infrastructure.Persistence.User.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs b/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs index 80ae6de..b33ab48 100644 --- a/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs +++ b/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs @@ -27,7 +27,8 @@ public class UserRepository : IUserRepository public async Task Save(Domain.Models.User.User user, CancellationToken cancellationToken = default) { - var userEntity = await _context.Users.FindAsync([new Guid(user.Id.IdValue), cancellationToken], cancellationToken: cancellationToken); + // ReSharper disable once MethodSupportsCancellation + var userEntity = await _context.Users.FindAsync(new Guid(user.Id.IdValue)); if (userEntity is not null) { diff --git a/dotnet/AipsWebApi/AipsWebApi.csproj b/dotnet/AipsWebApi/AipsWebApi.csproj index 7a38c76..bd3b180 100644 --- a/dotnet/AipsWebApi/AipsWebApi.csproj +++ b/dotnet/AipsWebApi/AipsWebApi.csproj @@ -7,7 +7,14 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/dotnet/AipsWebApi/Controllers/UserController.cs b/dotnet/AipsWebApi/Controllers/UserController.cs index f67757a..aa23ba4 100644 --- a/dotnet/AipsWebApi/Controllers/UserController.cs +++ b/dotnet/AipsWebApi/Controllers/UserController.cs @@ -1,5 +1,6 @@ using AipsCore.Application.Abstract; using AipsCore.Application.Models.User.Command.CreateUser; +using AipsCore.Domain.Common.Validation; using AipsCore.Domain.Models.User.ValueObjects; using Microsoft.AspNetCore.Mvc; @@ -12,8 +13,14 @@ public class UserController : ControllerBase [HttpPost] public async Task> CreateUser(CreateUserCommand command, IDispatcher dispatcher, CancellationToken cancellationToken) { - var userId = await dispatcher.Execute(command, cancellationToken); - - return Ok(userId.IdValue); + try + { + var userId = await dispatcher.Execute(command, cancellationToken); + return Ok(userId.IdValue); + } + catch (ValidationException validationException) + { + return BadRequest(validationException.ValidationErrors); + } } } \ No newline at end of file diff --git a/dotnet/AipsWebApi/Program.cs b/dotnet/AipsWebApi/Program.cs index ce9f99c..43918ca 100644 --- a/dotnet/AipsWebApi/Program.cs +++ b/dotnet/AipsWebApi/Program.cs @@ -1,13 +1,16 @@ using AipsCore.Infrastructure.DI; +using DotNetEnv; + +Env.Load(); var builder = WebApplication.CreateBuilder(args); -var configuration = builder.Configuration; +builder.Configuration.AddEnvironmentVariables(); builder.Services.AddControllers(); builder.Services.AddOpenApi(); -builder.Services.AddAips(configuration); +builder.Services.AddAips(builder.Configuration); var app = builder.Build(); @@ -17,7 +20,6 @@ if (app.Environment.IsDevelopment()) app.MapOpenApi(); } -app.UseHttpsRedirection(); app.UseAuthorization();