public async Task <UserRegistrationResponse> Register(UserRegistrationRequest request) { var(passwordHash, passwordSalt) = _passwordHashService.Generate(request.Password); var password = new Password(passwordHash, passwordSalt); var user = new User( request.Email, request.Name, password, request.DateOfBirth, _mapper.Map <GenderDto, Gender>(request.Gender), _clock.GetCurrentInstant() ); _dbContext.Users.Add(user); await _dbContext.SaveChangesAsync(); var registeredUserDto = new RegisteredUserDto(user.Id); return(new UserRegistrationResponse(registeredUserDto, _tokenService.Generate(user))); }