Exemplo n.º 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);
            }
            DataTable dt = new DataTable();

            UserModel userModel = new UserModel();

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

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

            return(userModel);
        }
        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());
        }
Exemplo n.º 3
0
        public UserModel ReturnUserByNamePassword(string userNickName, string userPassword)
        {
            if (!CheckStringFormat.IsBase64String(userPassword))
            {
                userPassword = ComputeHash.ComputeNewHash(userPassword);
            }

            var resultQuary = imdbFavoritesEntities.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
            });

            //var resultSP = imdbFavoritesEntities.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
            //});

            //if (GlobalVariable.queryType == 0)
            return(resultQuary.SingleOrDefault());
            //else
            //	return resultSP.SingleOrDefault();
        }