public UserModel GetOneUserByLogin(string userNickName, string userPassword) { if (userNickName.Equals("")) { throw new ArgumentOutOfRangeException(); } if (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.GetOneUserByLogin(userNickName, userPassword)); } foreach (DataRow ms in dt.Rows) { userModel = UserModel.ToObject(ms); } return(userModel); }
public UserModel GetOneUserByLogin(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, userPassword = u.userPassword, userEmail = u.userEmail, userGender = u.userGender, userBirthDate = u.userBirthDate, userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null, userLevel = u.userLevel }).SingleOrDefault()); } else { return(DB.GetOneUserByLogin(userNickName, userPassword).Select(u => new UserModel { userID = u.userID, userFirstName = u.userFirstName, userLastName = u.userLastName, userNickName = u.userNickName, userPassword = u.userPassword, userEmail = u.userEmail, userGender = u.userGender, userBirthDate = u.userBirthDate, userPicture = u.userPicture != null ? "/assets/images/users/" + u.userPicture : null, userLevel = u.userLevel }).SingleOrDefault()); } }
public UserModel GetOneUserByLogin(string userNickName, string userPassword) { 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, userPassword = user.userPassword, userEmail = user.userEmail, userGender = user.userGender, userBirthDate = user.userBirthDate, userPicture = user.userPicture != null ? "/assets/images/users/" + user.userPicture : null, userLevel = user.userLevel }).SingleOrDefault()); }