public async Task <int> MessageCount(PKMember member) { using (var conn = await _conn.Obtain()) return(await conn.QuerySingleAsync <int>("select count(*) from messages where member = @Id", member)); }
public async Task Store(ulong senderId, ulong messageId, ulong channelId, ulong originalMessage, PKMember member) { using (var conn = await _conn.Obtain()) await conn.ExecuteAsync("insert into messages(mid, channel, member, sender, original_mid) values(@MessageId, @ChannelId, @MemberId, @SenderId, @OriginalMid)", new { MessageId = messageId, ChannelId = channelId, MemberId = member.Id, SenderId = senderId, OriginalMid = originalMessage }); _logger.Information("Stored message {Message} in channel {Channel}", messageId, channelId); }
public async Task <AuxillaryProxyInformation> GetAuxillaryProxyInformation(ulong guild, PKSystem system, PKMember member) { using var conn = await _conn.Obtain(); var args = new { Guild = guild, System = system.Id, Member = member.Id }; var multi = await conn.QueryMultipleAsync(@" select servers.* from servers where id = @Guild; select * from system_guild where guild = @Guild and system = @System; select * from member_guild where guild = @Guild and member = @Member", args); return(new AuxillaryProxyInformation { Guild = (await multi.ReadSingleOrDefaultAsync <DatabaseCompatibleGuildConfig>()).Into(), SystemGuild = await multi.ReadSingleOrDefaultAsync <SystemGuildSettings>() ?? new SystemGuildSettings(), MemberGuild = await multi.ReadSingleOrDefaultAsync <MemberGuildSettings>() ?? new MemberGuildSettings() }); }