コード例 #1
0
        public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HashingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var newUser = new User
            {
                Email        = userForRegisterDto.Email,
                FirstName    = userForRegisterDto.FirstName,
                LastName     = userForRegisterDto.LastName,
                PasswordHash = passwordHash,
                PasswordSalt = passwordSalt,
                Status       = true
            };

            _userService.Add(newUser);
            var user = _userService.GetByMail(newUser.Email).Data;

            _userOperationClaimService.AddUserClaim(user);
            var newCustomer = new Customer {
                UserId = user.Id, CompanyName = $"{user.FirstName} {user.LastName}"
            };

            _customerService.Add(newCustomer);

            return(new SuccessDataResult <User>(user, Messages.UserRegistered));
        }