Presentation 2

This commit is contained in:
2026-02-08 20:17:01 +01:00
parent 41793f00c1
commit 70a1cf1544
17 changed files with 681 additions and 113 deletions

View File

@@ -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<UserId>, ICommand;
public record CreateUserCommand(string Username, string Email) : ICommand<UserId>;

View File

@@ -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<CreateUserCommand>
public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand, UserId>
{
private readonly IUserRepository _userRepository;
private readonly IUnitOfWork _unitOfWork;
@@ -15,11 +16,13 @@ public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
_unitOfWork = unitOfWork;
}
public async Task Handle(CreateUserCommand command, CancellationToken cancellationToken = default)
public async Task<UserId> 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;
}
}