コード例 #1
0
        // CRUD
        public long RegisterUserAccount(UserDto userDto, long userId)
        {
            // gen random string and hash
            var unhashedPassword = CommonHelperAppService.RandomString(8);

            userDto.Password = unhashedPassword;

            var user = Mapper.Map <User>(userDto);

            user.Password = HashPassword(unhashedPassword);

            _unitOfWork.UserRepository.Create(user);
            _unitOfWork.Save();


            // Mail
            MailerService.SendUserRegisteredEmail(userDto);

            // Audit
            _auditLogAppService.Audit(
                AppConstants.ActionTypeCreate,
                AppConstants.UserTableName,
                userId,
                user.Id);

            return(user.Id);
        }
コード例 #2
0
        public void Should_Send_New_User_Email_with_Account_Password()
        {
            // Arrange
            var userDto = new UserDto
            {
                Email              = "*****@*****.**",
                Firstname          = "Test",
                Lastname           = "User",
                IsAccountLocked    = false,
                IsActive           = true,
                SystemAccessRoleId = 1,
                Password           = CommonHelperAppService.RandomString(8)
            };

            // Act
            MailerService.SendUserRegisteredEmail(userDto);

            // Assert
            //Assert.AreEqual(expected, result);
        }