示例#1
0
        public async Task Update(NixChannel channel)
        {
            if (await Store(channel))
            {
                return;
            }

            await storage.UpdateAsync(channel);
        }
示例#2
0
        public async Task <bool> Store(NixChannel channel)
        {
            if (await storage.ExistsAsync <NixChannel>(CreateProperties(channel)))
            {
                return(false);
            }

            await storage.InsertAsync(channel);

            return(true);
        }
示例#3
0
        public async Task <bool> Remove(NixChannel channel)
        {
            if (!await storage.ExistsAsync <NixChannel>(CreateProperties(channel)))
            {
                return(false);
            }

            await storage.DeleteAsync <NixChannel>(CreateProperties(channel));

            return(true);
        }
示例#4
0
        public async Task <NixChannel> Get(SocketGuildChannel channel)
        {
            NixChannel nixChannel = await Get(channel.Id, channel.Guild.Id);

            if (nixChannel is null)
            {
                nixChannel = channel.GetNixChannel();
                await Store(nixChannel);

                return(nixChannel);
            }

            return(nixChannel);
        }
示例#5
0
 private object CreateProperties(NixChannel channel)
 {
     return(new { Id = channel.Id.ToString(), GuildId = channel.GuildId.ToString() });
 }