public bool IsUserExist(User user) { bool result = false; queryToExecute = string.Format( "SELECT * FROM users WHERE user_name=\"{0}\" AND password=\"{1}\";", user.Username, user.Password); MySqlDataReader reader = queryExecutor.ExecuteQuery(queryToExecute); if (reader.HasRows) { result = true; while (reader.Read()) { user.Id = reader.GetInt32(0); user.Email = reader.GetString(3); user.IsAdmin = reader.GetBoolean(4); } } reader.Close(); return result; }
public bool SignInUser(User user) { bool result = false; if (InputValidation.IsValidSignInInput(user.Username, user.Password)) { if (this.IsUserExist(user)) { result = true; } } return result; }
public User GetUser(User user) { User result = new User(); queryToExecute = string.Format( "SELECT * FROM users WHERE user_name=\"{0}\" AND password=\"{1}\";", user.Username, user.Password); MySqlDataReader reader = queryExecutor.ExecuteQuery(queryToExecute); if (reader.HasRows) { while (reader.Read()) { result.Id = reader.GetInt32(0); result.Username = reader.GetString(1); result.Password = reader.GetString(2); result.Email = reader.GetString(3); result.IsAdmin = reader.GetBoolean(4); } } reader.Close(); return result; }