From 50e87335f4dd361e9753c075c5ec67c364670bec Mon Sep 17 00:00:00 2001 From: Andrija Stevanovic Date: Thu, 5 Feb 2026 19:33:52 +0100 Subject: [PATCH] infrastructure restructure --- dotnet/AipsCore/Infrastructure/Db/AipsDbContext.cs | 9 --------- .../Infrastructure/Persistence/Db/AipsDbContext.cs | 8 ++++++++ .../{ => Persistence}/Db/EfUnitOfWork.cs | 2 +- .../{Entities => Persistence/User}/User.cs | 2 +- .../User}/UserRepository.cs | 14 ++++++-------- 5 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 dotnet/AipsCore/Infrastructure/Db/AipsDbContext.cs create mode 100644 dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs rename dotnet/AipsCore/Infrastructure/{ => Persistence}/Db/EfUnitOfWork.cs (88%) rename dotnet/AipsCore/Infrastructure/{Entities => Persistence/User}/User.cs (83%) rename dotnet/AipsCore/Infrastructure/{Repositories => Persistence/User}/UserRepository.cs (75%) diff --git a/dotnet/AipsCore/Infrastructure/Db/AipsDbContext.cs b/dotnet/AipsCore/Infrastructure/Db/AipsDbContext.cs deleted file mode 100644 index b39a190..0000000 --- a/dotnet/AipsCore/Infrastructure/Db/AipsDbContext.cs +++ /dev/null @@ -1,9 +0,0 @@ -using AipsCore.Infrastructure.Entities; -using Microsoft.EntityFrameworkCore; - -namespace AipsCore.Infrastructure.Db; - -public class AipsDbContext : DbContext -{ - public DbSet Users { get; set; } -} \ No newline at end of file diff --git a/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs new file mode 100644 index 0000000..500e317 --- /dev/null +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/AipsDbContext.cs @@ -0,0 +1,8 @@ +using Microsoft.EntityFrameworkCore; + +namespace AipsCore.Infrastructure.Persistence.Db; + +public class AipsDbContext : DbContext +{ + public DbSet Users { get; set; } +} \ No newline at end of file diff --git a/dotnet/AipsCore/Infrastructure/Db/EfUnitOfWork.cs b/dotnet/AipsCore/Infrastructure/Persistence/Db/EfUnitOfWork.cs similarity index 88% rename from dotnet/AipsCore/Infrastructure/Db/EfUnitOfWork.cs rename to dotnet/AipsCore/Infrastructure/Persistence/Db/EfUnitOfWork.cs index f31ed4d..0caab95 100644 --- a/dotnet/AipsCore/Infrastructure/Db/EfUnitOfWork.cs +++ b/dotnet/AipsCore/Infrastructure/Persistence/Db/EfUnitOfWork.cs @@ -1,6 +1,6 @@ using AipsCore.Domain.Abstract; -namespace AipsCore.Infrastructure.Db; +namespace AipsCore.Infrastructure.Persistence.Db; public class EfUnitOfWork : IUnitOfWork { diff --git a/dotnet/AipsCore/Infrastructure/Entities/User.cs b/dotnet/AipsCore/Infrastructure/Persistence/User/User.cs similarity index 83% rename from dotnet/AipsCore/Infrastructure/Entities/User.cs rename to dotnet/AipsCore/Infrastructure/Persistence/User/User.cs index 202f2ca..6cf01fc 100644 --- a/dotnet/AipsCore/Infrastructure/Entities/User.cs +++ b/dotnet/AipsCore/Infrastructure/Persistence/User/User.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace AipsCore.Infrastructure.Entities; +namespace AipsCore.Infrastructure.Persistence.User; public class User diff --git a/dotnet/AipsCore/Infrastructure/Repositories/UserRepository.cs b/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs similarity index 75% rename from dotnet/AipsCore/Infrastructure/Repositories/UserRepository.cs rename to dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs index 8314ac6..80ae6de 100644 --- a/dotnet/AipsCore/Infrastructure/Repositories/UserRepository.cs +++ b/dotnet/AipsCore/Infrastructure/Persistence/User/UserRepository.cs @@ -1,10 +1,8 @@ -using AipsCore.Domain.Common.ValueObjects; -using AipsCore.Domain.Models.User; using AipsCore.Domain.Models.User.External; using AipsCore.Domain.Models.User.ValueObjects; -using AipsCore.Infrastructure.Db; +using AipsCore.Infrastructure.Persistence.Db; -namespace AipsCore.Infrastructure.Repositories; +namespace AipsCore.Infrastructure.Persistence.User; public class UserRepository : IUserRepository { @@ -15,19 +13,19 @@ public class UserRepository : IUserRepository _context = context; } - public async Task Get(UserId userId, CancellationToken cancellationToken = default) + public async Task Get(UserId userId, CancellationToken cancellationToken = default) { var userEntity = await _context.Users.FindAsync([new Guid(userId.IdValue), cancellationToken], cancellationToken: cancellationToken); if (userEntity is null) return null; - return User.Create( + return Domain.Models.User.User.Create( userEntity.Id.ToString(), userEntity.Email, userEntity.Username); } - public async Task Save(User user, CancellationToken cancellationToken = default) + 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); @@ -40,7 +38,7 @@ public class UserRepository : IUserRepository } else { - userEntity = new Entities.User() + userEntity = new User() { Id = new Guid(user.Id.IdValue), Email = user.Email.EmailValue,