public async Task <UserDto> CreateUser(UserDto userDto) { var authenticationDto = new AuthenticationDto(); var userSpecification = new UserSpecification(). And(new UserNameSpecification()). And(new PasswordSpecification()). And(new UniqueUserSpecification(this.userRepository)); if (userSpecification.IsSatisfiedBy(userDto)) { string passwordSalt = ""; string passwordHash = ""; ECWRNGRfcSaltedHashManager.GenrateSaltedHash(userDto.Password, out passwordHash, out passwordSalt); var newUser = new Logins { UserName = userDto.UserName, PasswordSalt = passwordSalt, PasswordHash = passwordHash }; int identity = await this.userRepository.CreateLogin(newUser); if (identity <= 0) { userDto.AddRule("User", "Creation faild!"); } else { userDto.AddRule("Success", "Authentication is successfull."); } } return(userDto); }