Beispiel #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);
        }
Beispiel #3
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());
            }
        }