コード例 #1
0
        public async Task <ReportServer> Add(Server server, ulong channelId)
        {
            ReportServer reportServer = await reportServerRepository.Add(server, channelId);

            this.Added?.Invoke(this, reportServer);
            return(reportServer);
        }
コード例 #2
0
        public async Task Remove(ReportServer reportServer)
        {
            using (var conn = new MySqlConnection(this.connectionString))
            {
                await conn.OpenAsync();

                using (var cmd = new MySqlCommand($@"DELETE FROM report_servers 
                                                     WHERE server_id = @sid AND channel_id = @cid", conn))
                {
                    cmd.Parameters.AddWithValue("sid", reportServer.Server.Id);
                    cmd.Parameters.AddWithValue("cid", reportServer.ChannelId);

                    int rows = await cmd.ExecuteNonQueryAsync();

                    if (rows == 0)
                    {
                        throw new Exception("No rows deleted");
                    }
                }
            }
        }
コード例 #3
0
        public async Task Remove(ReportServer reportServer)
        {
            await reportServerRepository.Remove(reportServer);

            this.Removed?.Invoke(this, reportServer);
        }