public async Task <bool> Exists(ulong serverId, ulong channelId) { using (var conn = new MySqlConnection(this.connectionString)) { await conn.OpenAsync(); using (var cmd = new MySqlCommand($@"SELECT count(*) FROM discord_chat_channel_servers d JOIN servers s on d.server_id = s.id", conn)) { return((await cmd.GetCount()) == 1); } } }
public async Task <bool> Exists(Server server, ulong channelId) { using (var conn = new MySqlConnection(this.connectionString)) { await conn.OpenAsync(); using (var cmd = new MySqlCommand()) { cmd.Connection = conn; cmd.CommandText = @"SELECT COUNT(*) FROM subscribed_servers ss WHERE ss.server_id = @server_id AND ss.channel_id = @cid"; cmd.Parameters.AddWithValue("server_id", server.Id); cmd.Parameters.AddWithValue("cid", channelId); return((await cmd.GetCount()) == 1); } } }
public async Task <bool> Exists(string ip, int port, ulong channelId) { using (var conn = new MySqlConnection(this.connectionString)) { await conn.OpenAsync(); using (var cmd = new MySqlCommand()) { cmd.Connection = conn; cmd.CommandText = "SELECT COUNT(*) FROM subscribed_servers ss" + " JOIN servers s on ss.server_id = s.id" + " WHERE s.server_ip = @ip AND s.server_port = @port AND ss.channel_id = @cid "; cmd.Parameters.AddWithValue("ip", ip); cmd.Parameters.AddWithValue("port", port); cmd.Parameters.AddWithValue("cid", channelId); return((await cmd.GetCount()) == 1); } } }