Ejemplo n.º 1
0
        public void RemoveRisk(string nameOfInsuredObject, Risk risk, DateTime validTill, DateTime effectiveDate)
        {
            var policy          = GetInternalPolicy(nameOfInsuredObject, effectiveDate);
            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.RemoveRisk(risk, validTill);
            policyRepository.Update(policy);
        }
Ejemplo n.º 2
0
        public void AddRisk(string nameOfInsuredObject, Risk risk, DateTime validFrom, DateTime effectiveDate)
        {
            if (!AvailableRisks.Contains(risk))
            {
                throw new AddedRiskUnavailableException("Added risk is not avaiable for selling");
            }

            var policy          = GetInternalPolicy(nameOfInsuredObject, effectiveDate);
            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.AddRisk(risk, validFrom);
            policyRepository.Update(policy);
        }
Ejemplo n.º 3
0
        public IPolicy SellPolicy(string nameOfInsuredObject, DateTime validFrom, short validMonths, IList <Risk> selectedRisks)
        {
            var insurancePeriod   = new NewInsurancePeriod(validFrom, validMonths);
            var effectivePolicies = GetEffectivePolicies(nameOfInsuredObject, insurancePeriod);

            if (effectivePolicies.Any())
            {
                throw new ExistingEffectivePolicyException("Effective policy found that conflicts with requested validity period");
            }
            if (selectedRisks.Except(AvailableRisks).Any())
            {
                throw new InitialSelectedRiskUnavailableException("Some of the selected risks are not avaiable for selling");
            }

            var policy          = new Policy();
            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.Create(nameOfInsuredObject, insurancePeriod, selectedRisks);
            policyRepository.Add(policy);
            return(policy);
        }