public async Task <bool> Handle(RegisterUserCommand request, CancellationToken cancellationToken) { var userName = request.UserName.ToLower(); var existingUser = await _userQueries.FindByNameAsync(userName); if (existingUser != null) { throw new DomainException($"User name '{request.UserName}' already taken, please choose another name."); } var user = new Domain.AggregatesModel.UserAggregate.User(userName, request.Email, null, PasswordHasher.HashPassword(userName, request.Password), true, false, request.FirstName, request.LastName, request.Birthday); await _userRepository.AddAsync(user); return(await _userRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken)); }