Exemple #1
0
        public async Task ValidateCoveringPercentage(InsurancePolicyCoveringDTO dto)
        {
            var insurancePolicy = await _insurancePolicyService.GetById(dto.InsurancePolicyId);

            var currentCoveringList = _insurancePolicyCoveringRepository.GetAll(dto.InsurancePolicyId);
            int totalPercentage     = dto.Percentage;

            foreach (var item in currentCoveringList)
            {
                totalPercentage += item.Percentage;
            }

            if (totalPercentage > 100)
            {
                throw new ValidationException("The covering can't exceed 100%");
            }

            if (insurancePolicy.RiskTypeId == (int)RiskTypeEnum.High && totalPercentage > 50)
            {
                throw new ValidationException("The covering can't exceed 50%");
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetById(int id)
        {
            var result = await _insurancePolicyService.GetById(id);

            return(Ok(result));
        }