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(""); }
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 }); }
public async Task Add(Domain.Policy policy) { await elasticClient.IndexDocumentAsync(policy); }