infrastructure restructure

This commit is contained in:
2026-02-05 19:33:52 +01:00
parent 82d44c230f
commit 50e87335f4
5 changed files with 16 additions and 19 deletions

View File

@@ -1,9 +0,0 @@
using AipsCore.Infrastructure.Entities;
using Microsoft.EntityFrameworkCore;
namespace AipsCore.Infrastructure.Db;
public class AipsDbContext : DbContext
{
public DbSet<User> Users { get; set; }
}

View File

@@ -0,0 +1,8 @@
using Microsoft.EntityFrameworkCore;
namespace AipsCore.Infrastructure.Persistence.Db;
public class AipsDbContext : DbContext
{
public DbSet<User.User> Users { get; set; }
}

View File

@@ -1,6 +1,6 @@
using AipsCore.Domain.Abstract; using AipsCore.Domain.Abstract;
namespace AipsCore.Infrastructure.Db; namespace AipsCore.Infrastructure.Persistence.Db;
public class EfUnitOfWork : IUnitOfWork public class EfUnitOfWork : IUnitOfWork
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace AipsCore.Infrastructure.Entities; namespace AipsCore.Infrastructure.Persistence.User;
public class User public class User

View File

@@ -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.External;
using AipsCore.Domain.Models.User.ValueObjects; 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 public class UserRepository : IUserRepository
{ {
@@ -15,19 +13,19 @@ public class UserRepository : IUserRepository
_context = context; _context = context;
} }
public async Task<User?> Get(UserId userId, CancellationToken cancellationToken = default) public async Task<Domain.Models.User.User?> Get(UserId userId, CancellationToken cancellationToken = default)
{ {
var userEntity = await _context.Users.FindAsync([new Guid(userId.IdValue), cancellationToken], cancellationToken: cancellationToken); var userEntity = await _context.Users.FindAsync([new Guid(userId.IdValue), cancellationToken], cancellationToken: cancellationToken);
if (userEntity is null) return null; if (userEntity is null) return null;
return User.Create( return Domain.Models.User.User.Create(
userEntity.Id.ToString(), userEntity.Id.ToString(),
userEntity.Email, userEntity.Email,
userEntity.Username); 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); var userEntity = await _context.Users.FindAsync([new Guid(user.Id.IdValue), cancellationToken], cancellationToken: cancellationToken);
@@ -40,7 +38,7 @@ public class UserRepository : IUserRepository
} }
else else
{ {
userEntity = new Entities.User() userEntity = new User()
{ {
Id = new Guid(user.Id.IdValue), Id = new Guid(user.Id.IdValue),
Email = user.Email.EmailValue, Email = user.Email.EmailValue,