public async Task <Response> Register(RegisterUserRequest request) { try { var user = _mapper.Map <User>(request); var found = await _repository.GetByEmail(user.Email); if (found != null) { return(ConflictResponse("Esse email já está sendo utilizado")); } var saltedHash = _hashService.GenerateSaltedHash(request.Password); user.Salt = saltedHash.Salt; user.Hash = saltedHash.Hash; user.Role = EUserRole.DEVELOPER; user.CreatedAt = DateTime.Now; _repository.Add(user); if (await _repository.SaveChangesAsync()) { var response = _mapper.Map <UserResponse>(user); return(OkResponse(null, response)); } return(BadRequestResponse("Erro desconhecido")); } catch (Exception ex) { return(BadRequestResponse(ex.Message)); } }