public UserAccountResponse Create(CreateUserAccountRequest newAccountDTO) { //validate that the email is not already in use if (_repo.Exists(newAccountDTO.Email)) { throw new AppException($"Email {newAccountDTO.Email} is already registered"); } var newAccount = _mapper.Map <UserAccount>(newAccountDTO); newAccount.CreatedOn = DateTime.UtcNow; newAccount.VerifiedOn = DateTime.UtcNow; //hashpassword newAccount.PasswordHash = BC.HashPassword(newAccountDTO.Password); //save _repo.Create(newAccount); return(_mapper.Map <UserAccountResponse>(newAccount)); }
public ActionResult <UserAccountResponse> Create(CreateUserAccountRequest newAccountDTO) { var account = _service.Create(newAccountDTO); return(Ok(account)); }