user create command and user repo
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.User.Command;
|
||||
|
||||
public record CreateUserCommand(string Username, string Email) : ICommand<UserId>, ICommand;
|
||||
@@ -0,0 +1,23 @@
|
||||
using AipsCore.Application.Abstract.Command;
|
||||
using AipsCore.Domain.Common.ValueObjects;
|
||||
using AipsCore.Domain.Models.User.External;
|
||||
using AipsCore.Domain.Models.User.ValueObjects;
|
||||
|
||||
namespace AipsCore.Application.Models.User.Command.Handler;
|
||||
|
||||
public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
|
||||
{
|
||||
private readonly IUserRepository _userRepository;
|
||||
|
||||
public CreateUserCommandHandler(IUserRepository userRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
}
|
||||
|
||||
public async Task Handle(CreateUserCommand command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var user = Domain.Models.User.User.Create(command.Email, command.Username);
|
||||
|
||||
await _userRepository.Save(user, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user