Ejemplo n.º 1
0
        public async Task <bool> RemoveBinding(IEntity <ulong> binding)
        {
            using (var db = new BotFunctionSpamContext(dbOptions))
            {
                var entities = db.BotFunctionSpamBindings.Where(b => b.ChannelId == binding.Id);
                if (!entities.Any())
                {
                    return(false);
                }

                db.BotFunctionSpamBindings.RemoveRange(entities);
                await db.SaveChangesAsync();

                return(true);
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> AddBinding(IMessageChannel channel)
        {
            using (var db = new BotFunctionSpamContext(dbOptions))
            {
                if (db.BotFunctionSpamBindings.Any(b => b.ChannelId == channel.Id))
                {
                    return(false);
                }

                db.BotFunctionSpamBindings.Add(new BotFunctionSpamBinding
                {
                    ChannelId = channel.Id,
                });
                await db.SaveChangesAsync();

                return(true);
            }
        }