Пример #1
0
        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();
        }
Пример #2
0
 public void Save()
 {
     renoRatorDBEntities db = new renoRatorDBEntities();
     // salt and hash the password
     string salt = PasswordFunctions.CreateSalt(8);
     this.salt = salt;
     this.password = PasswordFunctions.CreateHash(this.password, salt);
     // add user to the database and save
     db.AddToUsers(this);
     db.SaveChanges();
 }