/// <summary>
        /// Retrieves eligibility parameters, transforms them into eligibilities, groups into rule sets and builds a Composite structure.
        /// </summary>
        /// <param name="productId">Build an eligibility structure belonging to the specified product.</param>
        /// <returns>Product's Composite eligibility structure.</returns>
        public IEligibility Create(int productId)
        {
            IQueryable <ProductEligibilityParam> eligibilityParameters = _prodEligRepository.GetProductEligibilityParams(productId);
            IList <IEligibility> eligibilities           = _eligibilityMapper.MapParamsToEligibility(eligibilityParameters.ToList <ProductEligibilityParam>());
            IList <IEligibility> rawRuleSetEligibilities = new List <IEligibility>();
            IEligibility         compositeEligibilities  = null;
            IEligibility         ruleSetEligibility      = null;
            int ruleSetCount = eligibilities.Any() ? eligibilities.Max(e => e.RuleSet) : 0;     // .Max() throws if collection is empty.

            for (int i = 1; i <= ruleSetCount; i++)
            {
                // Rule set 1 is handled differently from the subsequent rule sets.
                if (i == 1)
                {
                    ruleSetEligibility = CreateRuleSet <RuleSet1Eligibility>(eligibilities.Where(e => e.RuleSet == i));
                    rawRuleSetEligibilities.Add(ruleSetEligibility);
                }
                else
                {
                    ruleSetEligibility = CreateRuleSet <RuleSetOtherEligibility>(eligibilities.Where(e => e.RuleSet == i));
                    rawRuleSetEligibilities.Add(ruleSetEligibility);
                }
                ruleSetEligibility.RuleSet = i;
            }
            // Process the list of IEligibles into a Composite structure, based on rulesets.
            compositeEligibilities = CreateComposite(rawRuleSetEligibilities);
            return(compositeEligibilities);
        }
        // GET: Eligibility
        public ActionResult RawProducts()
        {
            ProductViewModel productVM = new ProductViewModel();

            productVM.ProductData = productDataRepository.ProductDatas.Where(p => p.Id == 1).FirstOrDefault();
            productVM.ProductEligibilityParams = productEligibilityParamRepository.GetProductEligibilityParams(1);
            return(View(productVM));
        }