示例#1
0
        public EnrollmentEntry ProcessEntry(string entry)
        {
            string[]        entries = entry.Split(",");
            EnrollmentEntry enrollmentEntry;

            // This is a placeholder.
            // TODO: Create this list using factory pattern instead.
            List <IEntryRuleValidator> entryRuleValidators = new List <IEntryRuleValidator>()
            {
                new RequiredFieldsValidator(),
                new DateStringValidator(),
                new PlanTypeValidator()
            };

            if (!ValidateEntryRules(entryRuleValidators, entries))
            {
                throw new ArgumentException(string.Format("The entry '{0}' is invalid.", entry));
            }
            else
            {
                enrollmentEntry = new EnrollmentEntry(
                    entries[0],
                    entries[1],
                    CreateDateFromString(entries[2]),
                    (Constants.PLAN_TYPE)Enum.Parse(typeof(Constants.PLAN_TYPE), entries[3]),
                    CreateDateFromString(entries[4])
                    );
            }

            // This is a placeholder.
            // TODO: Create this list using factory pattern instead.
            List <IBusinessRuleValidator> businessRuleValidators = new List <IBusinessRuleValidator>()
            {
                new DOBValidator(),
                new EffectiveDateValidator()
            };

            enrollmentEntry.status = ValidateBusinessRules(businessRuleValidators, enrollmentEntry);

            return(enrollmentEntry);
        }
示例#2
0
        private Constants.STATUS ValidateBusinessRules(List <IBusinessRuleValidator> rules, EnrollmentEntry entry)
        {
            Constants.STATUS status = Constants.STATUS.ACCEPTED;

            foreach (IBusinessRuleValidator rule in rules)
            {
                status = rule.ProcessBusinessRule(entry);
            }

            return(status);
        }