public void Save() { var db = new renoRatorDBEntities(); User newUser = new User(); newUser.userTypeID = this.userTypeID; newUser.fname = this.fname; newUser.lname = this.lname; newUser.email = this.email; newUser.password = this.password; if(!String.IsNullOrEmpty(this.bio)) newUser.bio = this.bio; if(this.profileGalleryID > 0) newUser.profileGalleryID = this.profileGalleryID; if (this.profilePhotoID > 0) newUser.profilePhotoID = this.profilePhotoID; if (this.addressID > 0) newUser.addressID = this.addressID; if (this.portfolioGalleryID > 0) newUser.portfolioGalleryID = this.portfolioGalleryID; // salt and hash the password string salt = PasswordFunctions.CreateSalt(8); newUser.salt = salt; newUser.password = PasswordFunctions.CreateHash(newUser.password, salt); db.AddToUsers(newUser); db.SaveChanges(); }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userID">Initial value of the userID property.</param> /// <param name="userTypeID">Initial value of the userTypeID property.</param> /// <param name="fname">Initial value of the fname property.</param> /// <param name="lname">Initial value of the lname property.</param> /// <param name="email">Initial value of the email property.</param> /// <param name="password">Initial value of the password property.</param> /// <param name="salt">Initial value of the salt property.</param> /// <param name="verified">Initial value of the verified property.</param> public static User CreateUser(global::System.Int32 userID, global::System.Int32 userTypeID, global::System.String fname, global::System.String lname, global::System.String email, global::System.String password, global::System.String salt, global::System.Boolean verified) { User user = new User(); user.userID = userID; user.userTypeID = userTypeID; user.fname = fname; user.lname = lname; user.email = email; user.password = password; user.salt = salt; user.verified = verified; return user; }