public void Register(RegisterUserAccountRequest regAccountDTO, string origin) { //check if the account already exists if (_repo.Exists(regAccountDTO.Email)) { //potentially send an email return; } var account = _mapper.Map <UserAccount>(regAccountDTO); //the first registered user is the admin bool isFirstAccount = _repo.Count() == 0; account.Role = isFirstAccount? Role.Admin : Role.User; account.CreatedOn = DateTime.UtcNow; account.VerificationToken = randomTokenString(); //hash password account.PasswordHash = BC.HashPassword(regAccountDTO.Password); //save the account _repo.Create(account); //send the registration email }