Exemple #1
0
        public MPRuleResult RulePasses(Dictionary <string, object> data)
        {
            var result = new MPRuleResult();

            if (!RuleIsActive())
            {
                result = new MPRuleResult
                {
                    Message    = "Rule Not Active",
                    RulePassed = true
                };
                return(result);
            }

            try
            {
                var genderId = data.ToInt("GenderId", true);
                result.RulePassed = (genderId == _genderRule.AllowedGenderId);
                result.Message    = result.RulePassed ? "Rule Passed" : $"Gender must be {_genderRule.AllowedGenderId}";
                return(result);
            }
            catch (Exception e)
            {
                throw new InvalidDataException("Invalid data provided to Gender Rule.", e);
            }
        }
Exemple #2
0
        public MPRuleResult RulePasses(Dictionary <string, object> data)
        {
            var result = new MPRuleResult();

            if (!RuleIsActive())
            {
                result.RulePassed = true;
                result.Message    = "Rule Not Active";
                return(result);
            }

            try
            {
                var registrants = data.ToInt("registrantCount", true);
                result.RulePassed = (registrants <= _registrationRule.MaximumRegistrants);
                result.Message    = result.RulePassed ? "Rule Passed" : $"Exceeded Maximum of {_registrationRule.MaximumRegistrants}";
                return(result);
            }
            catch (Exception e)
            {
                throw new InvalidDataException("Invalid data provided to registration rule.", e);
            }
        }