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 UpdateUser(UserModel userModel) { //var resultSP = imdbFavoritesEntities.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 //}); UserModel user; //if (GlobalVariable.queryType == 0) user = UpdateUserQuery(userModel); //else // user = resultSP.SingleOrDefault(); if (ComputeHash.ComputeNewHash(userModel.userPassword).Equals(user.userPassword)) { user.userPassword = userModel.userPassword; } return(user); }
private UserModel UpdateUserQuery(UserModel userModel) { string userPassword2 = ComputeHash.ComputeNewHash(userModel.userPassword); USER user = imdbFavoritesEntities.USERS.Where(u => u.userID.Equals(userModel.userID)).SingleOrDefault(); if (user == null) { return(null); } user.userID = userModel.userID; user.userFirstName = userModel.userFirstName; user.userLastName = userModel.userLastName; user.userNickName = userModel.userNickName; user.userPassword = userPassword2; user.userEmail = userModel.userEmail; user.userGender = userModel.userGender; user.userBirthDate = userModel.userBirthDate; user.userPicture = userModel.userPicture; user.userImdbPass = userModel.userImdbPass; try { imdbFavoritesEntities.SaveChanges(); } catch (ValidationException ex) { Debug.WriteLine(ex.Message); return(null); } return(GetOneUserById(user.userID)); }
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()); }
private UserModel AddUserQuery(UserModel userModel) { string userPassword2 = ComputeHash.ComputeNewHash(userModel.userPassword); USER user = new USER { userID = userModel.userID, userFirstName = userModel.userFirstName, userLastName = userModel.userLastName, userNickName = userModel.userNickName, userPassword = userPassword2, userEmail = userModel.userEmail, userGender = userModel.userGender, userBirthDate = userModel.userBirthDate, userPicture = userModel.userPicture, userImdbPass = userModel.userImdbPass }; imdbFavoritesEntities.USERS.Add(user); try { imdbFavoritesEntities.SaveChanges(); } catch (ValidationException ex) { Debug.WriteLine(ex.Message); return(null); } return(GetOneUserById(user.userID)); }
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); }
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); }
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); }
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()); }
public UserModel AddUser(UserModel userModel) { string orPass = userModel.userPassword; userModel.userPassword = ComputeHash.ComputeNewHash(userModel.userPassword); if (!_users.Find(Builders <UserModel> .Filter.Eq(user => user.userID, 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); }
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(); }
public LoginModel ReturnUserByNamePassword(LoginModel checkUser) { checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword); var resultQuary = imdbFavoritesEntities.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 }); //var resultSP = imdbFavoritesEntities.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 //}); //if (GlobalVariable.queryType == 0) return(resultQuary.SingleOrDefault()); //else // return resultSP.SingleOrDefault(); }
public UserModel AddUser(UserModel userModel) { string orPass = userModel.userPassword; DataTable dt = new DataTable(); userModel.userPassword = ComputeHash.ComputeNewHash(userModel.userPassword); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(UserStringsSql.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) { userPass = ComputeHash.ComputeNewHash(userPass); var resultQuary = imdbFavoritesEntities.USERS.Where(u => u.userPassword.Equals(userPass)).Select(u => new UserModel { userID = u.userID }); //var resultSP = imdbFavoritesEntities.ReturnUserIdByUserPass(userPass).Select(userID => new UserModel //{ // userID = userID //}); UserModel userModel; //if (GlobalVariable.queryType == 0) userModel = resultQuary.SingleOrDefault(); //else // userModel = resultSP.SingleOrDefault(); return(userModel.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 (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(UserStringsSql.ReturnUserByNamePassword(checkUser)); } foreach (DataRow ms in dt.Rows) { loginModel = LoginModel.ToObject(ms); } return(loginModel.userImdbPass); }
public string ReturnImdbPassByNamePassword(LoginModel checkUser) { checkUser.userPassword = ComputeHash.ComputeNewHash(checkUser.userPassword); var resultQuary = imdbFavoritesEntities.USERS.Where(u => u.userNickName.Equals(checkUser.userNickName)).Where(u => u.userPassword.Equals(checkUser.userPassword)).Select(u => new UserModel { userImdbPass = u.userImdbPass }); //var resultSP = imdbFavoritesEntities.ReturnImdbPassByNamePassword(checkUser.userNickName, checkUser.userPassword).Select(u => new UserModel //{ // userImdbPass = u.userImdbPass //}); UserModel userModel; //if (GlobalVariable.queryType == 0) userModel = resultQuary.SingleOrDefault(); //else // userModel = resultSP.SingleOrDefault(); return(userModel.userImdbPass); }
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); UserModel userModel = new UserModel(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(UserStringsSql.ReturnUserIdByUserPass(userPass)); } foreach (DataRow ms in dt.Rows) { userId = ms[0].ToString(); } return(userId); }