unit of work
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Abstract;
|
||||
using AipsCore.Domain.Models.User.External;
|
||||
|
||||
namespace AipsCore.Application.Models.User.Command.CreateUser;
|
||||
@@ -6,10 +7,12 @@ namespace AipsCore.Application.Models.User.Command.CreateUser;
|
||||
public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
|
||||
{
|
||||
private readonly IUserRepository _userRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public CreateUserCommandHandler(IUserRepository userRepository)
|
||||
public CreateUserCommandHandler(IUserRepository userRepository, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
public async Task Handle(CreateUserCommand command, CancellationToken cancellationToken = default)
|
||||
@@ -17,5 +20,6 @@ public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
|
||||
var user = Domain.Models.User.User.Create(command.Email, command.Username);
|
||||
|
||||
await _userRepository.Save(user, cancellationToken);
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user