Ejemplo n.º 1
0
        public void Insert(UserDTO UserDTO)
        {
            if (UserDTO != null)
            {
                User User = UserMapper.MapToDbEntity(UserDTO);
                #region Add Password Hash
                byte[] passwordHash, passwordSalt;
                PasswordAuthentication.CreatePasswordHash(UserDTO.Password, out passwordHash, out passwordSalt);
                User.PasswordHash = passwordHash;
                User.PasswordSalt = passwordSalt;
                #endregion

                DataContext.Add(User);
                DataContext.SaveChanges();
            }
        }//Regist
Ejemplo n.º 2
0
        }//Regist

        public void Update(UserDTO UserDTO)
        {
            User User = DataContext.Users.Find(UserDTO.Id);

            if (User != null)
            {
                User.LastName  = UserDTO.LastName;
                User.FirstName = UserDTO.FirstName;
                User.UserName  = UserDTO.UserName;
                #region Add Password Hash
                byte[] passwordHash, passwordSalt;
                PasswordAuthentication.CreatePasswordHash(UserDTO.Password, out passwordHash, out passwordSalt);
                User.PasswordHash = passwordHash;
                User.PasswordSalt = passwordSalt;
                #endregion

                DataContext.Users.Update(User);
                DataContext.SaveChanges();
            }
        }