public bool SaveSecurityQuestionAnswer(long userLoginId, string question, string answer) { using (IDataAccessAdapter myAdapter = PersistenceLayer.GetDataAccessAdapter()) { var userLoginEntity = new UserLoginEntity(userLoginId); if (myAdapter.FetchEntity(userLoginEntity)) { userLoginEntity.IsNew = false; userLoginEntity.HintQuestion = question; userLoginEntity.HintAnswer = _cryptographyService.Encrypt(answer); userLoginEntity.IsSecurityQuestionVerified = true; myAdapter.SaveEntity(userLoginEntity, true); return(true); } return(false); } }
public UserEntity CreateUserEntity(UserType userType) { if (userType == null) { throw new ArgumentNullException("userType"); } var userEntity = new UserEntity(userType.Id) { FirstName = userType.Name != null ? userType.Name.FirstName : string.Empty, LastName = userType.Name != null ? userType.Name.LastName : string.Empty, MiddleName = userType.Name != null ? userType.Name.MiddleName : string.Empty, HomeAddressId = userType.Address.Id, Dob = userType.DateOfBirth, Email1 = userType.Email != null?userType.Email.ToString() : string.Empty, Email2 = userType.AlternateEmail != null?userType.AlternateEmail.ToString() : string.Empty, PhoneCell = userType.MobilePhoneNumber != null ? userType.MobilePhoneNumber.AreaCode + userType.MobilePhoneNumber.Number : string.Empty, PhoneHome = userType.HomePhoneNumber != null ? userType.HomePhoneNumber.AreaCode + userType.HomePhoneNumber.Number : string.Empty, PhoneOffice = userType.OfficePhoneNumber != null ? userType.OfficePhoneNumber.AreaCode + userType.OfficePhoneNumber.Number : string.Empty, PhoneOfficeExtension = userType.PhoneOfficeExtension, DefaultRoleId = (long)userType.DefaultRole, CreatedByOrgRoleUserId = (userType.DataRecorderMetaData != null && userType.DataRecorderMetaData.DataRecorderCreator != null) ? userType.DataRecorderMetaData.DataRecorderCreator.Id == 0 ? (long?)null : userType.DataRecorderMetaData.DataRecorderCreator.Id : (long?)null, ModifiedByOrgRoleUserId = (userType.DataRecorderMetaData != null && userType.DataRecorderMetaData.DataRecorderModifier != null) ? userType.DataRecorderMetaData.DataRecorderModifier.Id == 0 ? (long?)null : userType.DataRecorderMetaData.DataRecorderModifier.Id : (long?)null, DateCreated = userType.DataRecorderMetaData != null ? userType.DataRecorderMetaData.DateCreated : DateTime.Now, DateModified = userType.DataRecorderMetaData != null && userType.DataRecorderMetaData.DateModified.HasValue ? userType.DataRecorderMetaData.DateModified.Value : DateTime.Now, Ssn = !string.IsNullOrEmpty(userType.Ssn) ? _cryptographyService.Encrypt(userType.Ssn) : userType.Ssn, IsActive = true, UserLogin = _userLoginFactory.CreateUserLoginEntity(userType.UserLogin, userType.Id), IsNew = userType.Id <= 0 }; if (userType.Id == 0) { userEntity.CreatedByOrgRoleUserId = (userType.DataRecorderMetaData != null) ? userType.DataRecorderMetaData.DataRecorderCreator. OrganizationId : (long?)null; } return(userEntity); }
public void Encrypt() { var password = _passwordCryptographyService.Encrypt(Password); var customerKey = _passwordCryptographyService.Encrypt(CustomerKey); }