public UserAccount CreateObject(UserAccount userAccount) { userAccount.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(userAccount, this)) { userAccount.Username = userAccount.Username.Trim(); StringEncryption se = new StringEncryption(); //string realpassword = userAccount.Password; userAccount.Password = se.Encrypt(userAccount.Password); _repository.CreateObject(userAccount); //userAccount.Password = realpassword; // set back to unencrypted password to prevent encrypting an already encrypted password on the next update } return(userAccount); }