public ActionResult <AuthenticationResult> CreateUser(UserCreateDto userCreateDto) { var userModel = _mapper.Map <User>(userCreateDto); if (_repo.GetUserByUsername(userModel.username) != null) { return(BadRequest(new { error = ErrorMessages.userExists })); } userModel.password = _auth.HashPassword(userModel.password); _repo.CreateUser(userModel); _repo.SaveChanges(); //var userReadDto = _mapper.Map<UserReadDto>(userModel); //return CreatedAtRoute(nameof(GetUserByUsername), new {username = userReadDto.username}, userReadDto); return(Ok(new AuthenticationResultSuccessDto { success = true, token = _auth.CreateToken(userModel) })); }