예제 #1
0
        public void RemoveRisk(string nameOfInsuredObject, Risk risk, DateTime validTill, DateTime effectiveDate)
        {
            var policyId = IdGenerator.ConstructPolicyId(nameOfInsuredObject, effectiveDate);

            var policyModel = _policyRepository.Get(policyId);

            if (validTill.Date > policyModel.ValidTill.Date)
            {
                throw new RiskRemovalDateException();
            }

            var riskId = IdGenerator.ConstructRiskId(risk.Name, nameOfInsuredObject, effectiveDate);

            var riskModel = _riskRepository.Get(riskId);

            var updatedRiskModel = new RiskModel
            {
                Name                = riskModel.Name,
                ValidFrom           = riskModel.ValidFrom,
                PolicyEffectiveDate = riskModel.PolicyEffectiveDate,
                PolicyId            = riskModel.PolicyId,
                Id          = riskModel.Id,
                ValidTill   = validTill,
                YearlyPrice = riskModel.YearlyPrice
            };

            _riskRepository.Edit(updatedRiskModel);
        }