Presentation 2
This commit is contained in:
@@ -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>;
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user