Exemplo n.º 1
0
 public void Update(string rulename, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction channelRuleAction)
 {
     RuleName           = rulename;
     BansForTrigger     = bansForTrigger;
     TimeoutsForTrigger = timeoutsForTrigger;
     ActionOnTrigger    = channelRuleAction;
 }
Exemplo n.º 2
0
 public ChannelRule(string ruleName, Tag tag, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction actionOnTrigger)
 {
     RuleId             = Guid.NewGuid();
     Tag                = tag;
     BansForTrigger     = bansForTrigger;
     TimeoutsForTrigger = timeoutsForTrigger;
     ActionOnTrigger    = actionOnTrigger;
     RuleName           = ruleName;
 }
Exemplo n.º 3
0
        public async Task <IResult <Channel> > UpdateRuleForChannel(string channelName, Guid ruleId, string rulename, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction channelRuleAction, IApplicationContext context)
        {
            var fetch = await FetchAndCheckAccess(channelName, context).ConfigureAwait(false);

            if (fetch.State != ResultState.Success)
            {
                return(fetch);
            }

            var channel = fetch.Data;

            channel.UpdateRule(ruleId, rulename, bansForTrigger, timeoutsForTrigger, channelRuleAction);

            await channelRepository.Upsert(channel).ConfigureAwait(false);

            return(Result <Channel> .Succeeded(channel));
        }
Exemplo n.º 4
0
        public async Task <IResult <Channel> > AddRuleToChannel(string channelName, string ruleName, Guid tagId, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction channelRuleAction, IApplicationContext context)
        {
            var fetch = await FetchAndCheckAccess(channelName, context).ConfigureAwait(false);

            if (fetch.State != ResultState.Success)
            {
                return(fetch);
            }

            var channel = fetch.Data;
            var tag     = await tagRepository.Get(tagId).ConfigureAwait(false);

            channel.AddRule(ruleName, tag, bansForTrigger, timeoutsForTrigger, channelRuleAction);

            await channelRepository.Upsert(channel).ConfigureAwait(false);

            return(Result <Channel> .Succeeded(channel));
        }
Exemplo n.º 5
0
        internal void UpdateRule(Guid ruleId, string rulename, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction channelRuleAction)
        {
            if (channelRules == null)
            {
                channelRules = new List <ChannelRule>();
            }

            var existingRule = channelRules.Find(x => x.RuleId == ruleId);

            if (existingRule != null)
            {
                channelRules.Remove(existingRule);
                existingRule.Update(rulename, bansForTrigger, timeoutsForTrigger, channelRuleAction);
                channelRules.Add(existingRule);
            }
        }
Exemplo n.º 6
0
        public void AddRule(string ruleName, Tag tag, int bansForTrigger, int timeoutsForTrigger, ChannelRuleAction channelRuleAction)
        {
            if (channelRules == null)
            {
                channelRules = new List <ChannelRule>();
            }

            // we might need to add a check if there is an equivelant rule? (No need to have two that does the exact same)
            var newRule = new ChannelRule(ruleName, tag, bansForTrigger, timeoutsForTrigger, channelRuleAction);

            channelRules.Add(newRule);
        }