Пример #1
0
        public UserModel ReturnUserByNamePassword(string userNickName, string userPassword)
        {
            if (userNickName == null || userNickName.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            if (userPassword == null || userPassword.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }

            if (!CheckStringFormat.IsBase64String(userPassword))
            {
                userPassword = ComputeHash.ComputeNewHash(userPassword);
            }

            return((from user in _users.AsQueryable()
                    where user.userNickName.Equals(userNickName)
                    where user.userPassword.Equals(userPassword)
                    select new UserModel
            {
                userID = user.userID,
                userFirstName = user.userFirstName,
                userLastName = user.userLastName,
                userNickName = user.userNickName,
                userBirthDate = user.userBirthDate,
                userGender = user.userGender,
                userEmail = user.userEmail,
                userPassword = user.userPassword,
                userPicture = user.userPicture != null ? "/assets/images/users/" + user.userPicture : null,
                userImdbPass = user.userImdbPass
            }).SingleOrDefault());
        }
        public UserModel ReturnUserByNamePassword(string userNickName, string userPassword)
        {
            if (userNickName == null || userNickName.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            if (userPassword == null || userPassword.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }

            if (!CheckStringFormat.IsBase64String(userPassword))
            {
                userPassword = ComputeHash.ComputeNewHash(userPassword);
            }
            DataTable dt = new DataTable();

            UserModel userModel = new UserModel();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(UserStringsMySql.ReturnUserByNamePassword(userNickName, userPassword));
            }

            foreach (DataRow ms in dt.Rows)
            {
                userModel = UserModel.ToObject(ms);
            }

            return(userModel);
        }
Пример #3
0
        public string ReturnUserIdByUserPass(string userPass)
        {
            string userId = "";

            if (userPass.Equals(string.Empty) || userPass.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            userPass = ComputeHash.ComputeNewHash(userPass);

            UserModel userModel = _users.Find <UserModel>(user => user.userPassword.Equals(userPass)).FirstOrDefault();

            userId = userModel.userID;
            return(userId);
        }
Пример #4
0
        public string ReturnImdbPassByNamePassword(LoginModel checkUser)
        {
            checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword);
            if (checkUser == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            string userImdbPass = "";

            UserModel userModel = _users.Find <UserModel>(user => user.userNickName.Equals(checkUser.userNickName) && user.userPassword.Equals(checkUser.userPassword)).FirstOrDefault();

            userImdbPass = userModel.userImdbPass;

            return(userImdbPass);
        }
Пример #5
0
        public UserModel UpdateUser(UserModel userModel)
        {
            UserModel user;

            if (GlobalVariable.queryType == 0)
            {
                string userPassword2 = ComputeHash.ComputeNewHash(userModel.userPassword);
                USER   user2         = DB.USERS.Where(u => u.userID.Equals(userModel.userID)).SingleOrDefault();
                if (user2 == null)
                {
                    return(null);
                }
                user2.userID        = userModel.userID;
                user2.userFirstName = userModel.userFirstName;
                user2.userLastName  = userModel.userLastName;
                user2.userNickName  = userModel.userNickName;
                user2.userPassword  = userPassword2;
                user2.userEmail     = userModel.userEmail;
                user2.userGender    = userModel.userGender;
                user2.userBirthDate = userModel.userBirthDate;
                user2.userPicture   = userModel.userPicture;
                user2.userImdbPass  = userModel.userImdbPass;
                DB.SaveChanges();
                user = GetOneUserById(user2.userID);
            }
            else
            {
                user = DB.UpdateUser(userModel.userID, userModel.userFirstName, userModel.userLastName, userModel.userNickName, userModel.userBirthDate, userModel.userGender, userModel.userEmail, ComputeHash.ComputeNewHash(userModel.userPassword), userModel.userPicture, userModel.userImdbPass).Select(u => new UserModel
                {
                    userID        = u.userID,
                    userFirstName = u.userFirstName,
                    userLastName  = u.userLastName,
                    userNickName  = u.userNickName,
                    userBirthDate = u.userBirthDate,
                    userGender    = u.userGender,
                    userEmail     = u.userEmail,
                    userPassword  = u.userPassword,
                    userPicture   = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null,
                    userImdbPass  = u.userImdbPass
                }).SingleOrDefault();
            }

            if (ComputeHash.ComputeNewHash(userModel.userPassword).Equals(user.userPassword))
            {
                user.userPassword = userModel.userPassword;
            }
            return(user);
        }
Пример #6
0
        public UserModel UpdateUser(UserModel userModel)
        {
            string orPass = userModel.userPassword;

            userModel.userPassword = ComputeHash.ComputeNewHash(userModel.userPassword);

            _users.ReplaceOne(user => user.userID.Equals(userModel.userID), userModel);
            UserModel tmpUserModel = ReturnUserByNamePassword(userModel.userNickName, userModel.userPassword);

            if (ComputeHash.ComputeNewHash(orPass).Equals(tmpUserModel.userPassword))
            {
                tmpUserModel.userPassword = orPass;
            }

            return(tmpUserModel);
        }
Пример #7
0
        public LoginModel ReturnUserByNamePassword(LoginModel checkUser)
        {
            checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword);
            if (checkUser == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            return((from user in _users.AsQueryable()
                    where user.userNickName.Equals(checkUser.userNickName)
                    where user.userPassword.Equals(checkUser.userPassword)
                    select new LoginModel
            {
                userNickName = user.userNickName,
                userImdbPass = user.userImdbPass,
                userPicture = user.userPicture != null ? "/assets/images/users/" + user.userPicture : null
            }).SingleOrDefault());
        }
Пример #8
0
        public UserModel AddUser(UserModel userModel)
        {
            string orPass = userModel.userPassword;

            userModel.userPassword = ComputeHash.ComputeNewHash(userModel.userPassword);

            if (!_users.Find <UserModel>(u => u.userID.Equals(userModel.userID)).Any())
            {
                _users.InsertOne(userModel);
            }
            UserModel tmpUserModel = ReturnUserByNamePassword(userModel.userNickName, userModel.userPassword);

            if (ComputeHash.ComputeNewHash(orPass).Equals(tmpUserModel.userPassword))
            {
                tmpUserModel.userPassword = orPass;
            }

            return(tmpUserModel);
        }
Пример #9
0
        public UserModel ReturnUserByNamePassword(string userNickName, string userPassword)
        {
            if (!CheckStringFormat.IsBase64String(userPassword))
            {
                userPassword = ComputeHash.ComputeNewHash(userPassword);
            }

            if (GlobalVariable.queryType == 0)
            {
                return(DB.USERS.Where(u => u.userNickName.Equals(userNickName)).Where(u => u.userPassword.Equals(userPassword)).Select(u => new UserModel
                {
                    userID = u.userID,
                    userFirstName = u.userFirstName,
                    userLastName = u.userLastName,
                    userNickName = u.userNickName,
                    userBirthDate = u.userBirthDate,
                    userGender = u.userGender,
                    userEmail = u.userEmail,
                    userPassword = u.userPassword,
                    userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null,
                    userImdbPass = u.userImdbPass
                }).SingleOrDefault());
            }
            else
            {
                return(DB.ReturnUserByNameLogin(userNickName, userPassword).Select(u => new UserModel
                {
                    userID = u.userID,
                    userFirstName = u.userFirstName,
                    userLastName = u.userLastName,
                    userNickName = u.userNickName,
                    userBirthDate = u.userBirthDate,
                    userGender = u.userGender,
                    userEmail = u.userEmail,
                    userPassword = u.userPassword,
                    userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null,
                    userImdbPass = u.userImdbPass
                }).SingleOrDefault());
            }
        }
        public UserModel AddUser(UserModel userModel)
        {
            string    orPass = userModel.userPassword;
            DataTable dt     = new DataTable();

            userModel.userPassword = ComputeHash.ComputeNewHash(userModel.userPassword);
            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(UserStringsMySql.AddUser(userModel));
            }
            foreach (DataRow ms in dt.Rows)
            {
                userModel = UserModel.ToObject(ms);
            }

            if (ComputeHash.ComputeNewHash(orPass).Equals(userModel.userPassword))
            {
                userModel.userPassword = orPass;
            }

            return(userModel);
        }
        public string ReturnUserIdByUserPass(string userPass)
        {
            DataTable dt     = new DataTable();
            string    userId = "";

            if (userPass.Equals(string.Empty) || userPass.Equals(""))
            {
                throw new ArgumentOutOfRangeException();
            }
            userPass = ComputeHash.ComputeNewHash(userPass);

            using (SqlCommand command = new SqlCommand())
            {
                dt = GetMultipleQuery(UserStringsSql.ReturnUserIdByUserPass(userPass));
            }
            foreach (DataRow ms in dt.Rows)
            {
                userId = ms[0].ToString();
            }

            return(userId);
        }
        public string ReturnImdbPassByNamePassword(LoginModel checkUser)
        {
            DataTable dt = new DataTable();

            checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword);
            if (checkUser == null)
            {
                throw new ArgumentOutOfRangeException();
            }
            LoginModel loginModel = new LoginModel();

            using (MySqlCommand command = new MySqlCommand())
            {
                dt = GetMultipleQuery(UserStringsMySql.ReturnUserByNamePassword(checkUser));
            }

            foreach (DataRow ms in dt.Rows)
            {
                loginModel = LoginModel.ToObject(ms);
            }

            return(loginModel.userImdbPass);
        }
Пример #13
0
        public string ReturnUserIdByUserPass(string userPass)
        {
            userPass = ComputeHash.ComputeNewHash(userPass);

            UserModel userModel;

            if (GlobalVariable.queryType == 0)
            {
                userModel = DB.USERS.Where(u => u.userPassword.Equals(userPass)).Select(u => new UserModel
                {
                    userID = u.userID
                }).SingleOrDefault();
            }
            else
            {
                userModel = DB.ReturnUserIdByUserPass(userPass).Select(userID => new UserModel
                {
                    userID = userID
                }).SingleOrDefault();
            }

            return(userModel.userID);
        }
Пример #14
0
        public string ReturnImdbPassByNamePassword(LoginModel checkUser)
        {
            checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword);

            UserModel userModel;

            if (GlobalVariable.queryType == 0)
            {
                userModel = DB.USERS.Where(u => u.userNickName.Equals(checkUser.userNickName)).Where(u => u.userPassword.Equals(checkUser.userPassword)).Select(u => new UserModel
                {
                    userImdbPass = u.userImdbPass
                }).SingleOrDefault();
            }
            else
            {
                userModel = DB.ReturnImdbPassByNamePassword(checkUser.userNickName, checkUser.userPassword).Select(u => new UserModel
                {
                    userImdbPass = u.userImdbPass
                }).SingleOrDefault();
            }

            return(userModel.userImdbPass);
        }
Пример #15
0
        public LoginModel ReturnUserByNamePassword(LoginModel checkUser)
        {
            checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword);

            if (GlobalVariable.queryType == 0)
            {
                return(DB.USERS.Where(u => u.userNickName.Equals(checkUser.userNickName)).Where(u => u.userPassword.Equals(checkUser.userPassword)).Select(u => new LoginModel
                {
                    userNickName = u.userNickName,
                    userImdbPass = u.userImdbPass,
                    userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null
                }).SingleOrDefault());
            }
            else
            {
                return(DB.ReturnUserByNamePassword(checkUser.userNickName, checkUser.userPassword).Select(u => new LoginModel
                {
                    userNickName = u.userNickName,
                    userImdbPass = u.userImdbPass,
                    userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null
                }).SingleOrDefault());
            }
        }