Ejemplo n.º 1
0
        // Execute Rule /  Rules
        #endregion

        #region rule evaluation

        public static IEntity ExecuteRule(string ruleName, object obj)
        {
            Rule    rule   = GetRuleByName(ruleName).Value;
            IEntity entity = EntityFacade.ConvertObjectToEntity(obj, rule.EntityName);

            if (EvaluateCondition(rule, entity))
            {
                return(ExecuteRuleExecutions(rule, entity));
            }
            return(entity);
        }
Ejemplo n.º 2
0
        public static IEntity ExecuteRuleGroup(string ruleGroupName, object obj)
        {
            List <Rule> rules = GetRulesInGroup(ruleGroupName).Select(r => r.Value).ToList();;

            if (rules.Count > 0)
            {
                IEntity entity = EntityFacade.ConvertObjectToEntity(obj, rules[0].EntityName);
                rules = rules.OrderByDescending(r => r.Priority).ToList();
                foreach (Rule rule in rules)
                {
                    entity = ExecuteRule(rule.RuleName, entity);
                }
                return(entity);
            }
            return(null);
        }