Ejemplo n.º 1
0
        public string CoverageByPolicyCanBeCreated(Domain.Policy policy)
        {
            //var typeOfRiskRepository = new TypeOfRiskRepository();
            //var highTypeOfRiskId = typeOfRiskRepository.GetAll().Where(r => r.Name == "High").SingleOrDefault().Id;
            var coverageByPolicy = policy.CoveragesByPolicy[0];

            if (policy.TypeOfRisk.Name == "High" && coverageByPolicy.Percentage > 50)
            {
                return("The type of risk is 'High', so the coverage percentage can't be major than 50%");
            }

            return("");
        }
Ejemplo n.º 2
0
        public async Task <CreatePolicyResponse> CreatePolicyAsync(CreatePolicyCommand command)
        {
            var policy = new Domain.Policy(command.PolicyDateFrom, command.PolicyDateTo);

            _policyContext.Policy.Add(policy);

            var insured = new Insured(command.InsuredFirstName, command.InsuredLastName, command.InsuredNumber);

            policy.AttachInsured(insured);
            policy.AddProducts(command.ProductsCodes.ToList());

            await _policyContext.SaveChangesAsync();

            return(new CreatePolicyResponse {
                PolicyId = policy.PolicyId
            });
        }
Ejemplo n.º 3
0
 public async Task Add(Domain.Policy policy)
 {
     await elasticClient.IndexDocumentAsync(policy);
 }