user create command and user repo

This commit is contained in:
2026-02-04 22:18:05 +01:00
parent b73fd8eb05
commit 01f25fb093
10 changed files with 136 additions and 5 deletions

View File

@@ -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;

View File

@@ -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);
}
}