infrastructure restructure
This commit is contained in:
@@ -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; }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace AipsCore.Infrastructure.Persistence.Db;
|
||||||
|
|
||||||
|
public class AipsDbContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<User.User> Users { get; set; }
|
||||||
|
}
|
||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
@@ -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,
|
||||||
Reference in New Issue
Block a user