public List <FollowingTable> GetFollowers(int ChannelID) { List <FollowingTable> ChannelFollowers = new List <FollowingTable>(); con = new MySqlConnection(ConnectionString()); FollowingTable FollowingTableInfo = new FollowingTable(); con.Open(); if (con.State == ConnectionState.Open) { MySqlCommand cmd = new MySqlCommand(@" SELECT FollowingUserID FROM FollowingTable WHERE FollowedChannelID = @ChannelID)", con); cmd.Parameters.AddWithValue("@ChannelID", ChannelID); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { FollowingTableInfo.FollowedChannelID = Convert.ToInt32(rdr["FollowedChannelID"]); FollowingTableInfo.FollowingUserID = Convert.ToInt32(rdr["FollowingUserID"]); ChannelFollowers.Add(FollowingTableInfo); } rdr.Close(); con.Close(); } return(ChannelFollowers); }
public bool UpdateFollower(FollowingTable UpdateInfo) { bool result = false; con = new MySqlConnection(ConnectionString()); con.Open(); if (con.State == ConnectionState.Open) { MySqlCommand cmd = new MySqlCommand(@" UPDATE FollowingTable SET ", con); cmd.CommandText += " FollowedChannelID = @FollowedChannelID,"; cmd.CommandText += " FollowingUserID = @FollowingUserID,"; cmd.CommandText += " WHERE FollowingUserID = @FollowingUserID)"; cmd.Parameters.AddWithValue("@FollowingUserID", UpdateInfo.FollowingUserID); cmd.Parameters.AddWithValue("@FollowedChannelID", UpdateInfo.FollowedChannelID); cmd.ExecuteNonQuery(); con.Close(); result = true; } return(result); }