private INotification ValidateAndCreate(Domain.User user) { var notification = _validator.Validate(user); if (notification.IsValid()) { //verify valid password if (!_passwordValidator.ValidatePassword(user.Password)) { notification.RegisterMessage("Password", _settings.Password.GetValidationMessage(), Severity.Error); return notification; } //make sure user is unique if(_userRepository.FindBy(x => x.UserName, user.UserName) != null) { notification.RegisterMessage("UserName", "User name already exists!", Severity.Error); return notification; } //make sure email is unique if (_userRepository.FindBy(x => x.Email, user.Email) != null) { notification.RegisterMessage("Email", "Email already exists!", Severity.Error); return notification; } switch (_settings.Password.PasswordFormat) { case PasswordFormat.Hashed: user.SetPassword(_passwordHelperService); break; case PasswordFormat.Clear: user.SetPassword(new ClearPasswordHelper()); break; case PasswordFormat.Encrypted: throw new NotImplementedException(); break; default: throw new ArgumentOutOfRangeException(); } _userRepository.Save(user); } return notification; }