Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #3
0
 public bool CheckBinding(IMessageChannel channel)
 {
     using (var db = new BotFunctionSpamContext(dbOptions))
         return(db.BotFunctionSpamBindings.All(b => b.ChannelId != channel.Id));
 }