コード例 #1
0
        public CustomerPolicyResponse CreateCustomerPolicy(CustomerPolicyRequest customerPolicyRequest)
        {
            TSeg_Clientes_Polizas customerPolicy    = CustomerPolicyMapper.TransformCustomerPolicyRequestToTSegClientePoliza(customerPolicyRequest);
            TSeg_Clientes_Polizas customerPolicyOut = CustomerPolicyDomainService.CreateCustomerPolicy(customerPolicy);

            return(customerPolicyOut != null?CustomerPolicyMapper.TransformTSegClientePolizaToCustomerPolicyResponse(customerPolicyOut) : null);
        }
コード例 #2
0
        public ActionResult AddPolicy(long customerId, long policyId, short meses, string riesgo, decimal precio, short cobertura)
        {
            try {
                CustomerPolicyRequest customerPolicyRequest = new CustomerPolicyRequest
                {
                    id_cliente      = customerId,
                    id_poliza       = policyId,
                    meses_cobertura = meses,
                    riesgo          = riesgo,
                    precio          = precio,
                    cobertura       = cobertura,
                    fecha_inicio    = DateTime.Now
                };

                CustomerPolicyValidation.validationsAddPolicy(customerPolicyRequest);

                CustomerPolicyResponse response = CustomerPolicyApplicationService.CreateCustomerPolicy(customerPolicyRequest);
                return(RedirectToAction("PoliciesDetails", new { id = customerId }));
            }
            catch
            {
                CustomerResponse customer = CustomerApplicationService.ReadCustomerById(customerId);
                ViewBag.FullName       = customer.apellidos + " " + customer.nombres;
                ViewBag.CustomerId     = customer.id;
                ViewBag.Identification = customer.identificacion;

                List <PolicyResponse> policies = PolicyApplicationService.ReadPolicies();
                ViewBag.policies = new SelectList(policies, nameof(PolicyResponse.id), nameof(PolicyResponse.nombre));

                ViewBag.Error = "La póliza no se pudo adicionar al cliente.";

                return(View("~/Views/Customers/AddPolicy.cshtml"));
            }
        }
コード例 #3
0
 public static void validationsAddPolicy(CustomerPolicyRequest customerPolicy)
 {
     if (customerPolicy.id_cliente <= 0)
     {
         throw new Exception("El id de cliente no puede ser menor a 1");
     }
     if (customerPolicy.id_poliza <= 0)
     {
         throw new Exception("El id de póliza no puede ser menor a 1");
     }
     if (customerPolicy.cobertura <= 0 || customerPolicy.cobertura > 100)
     {
         throw new Exception("El porcentaje de cobertura debe estar entre 0 y 100");
     }
     if (customerPolicy.riesgo.Equals("Alto") && customerPolicy.cobertura > 50)
     {
         throw new Exception("Para riesgo alto el porcentaje de cobertura debe ser máximo 50");
     }
 }
コード例 #4
0
 public static TSeg_Clientes_Polizas TransformCustomerPolicyRequestToTSegClientePoliza(CustomerPolicyRequest customerPolicyRequest)
 {
     return(new TSeg_Clientes_Polizas
     {
         cobertura = customerPolicyRequest.cobertura,
         fecha_inicio = customerPolicyRequest.fecha_inicio,
         meses_cobertura = customerPolicyRequest.meses_cobertura,
         precio = customerPolicyRequest.precio,
         riesgo = customerPolicyRequest.riesgo,
         id_poliza = customerPolicyRequest.id_poliza,
         id_cliente = customerPolicyRequest.id_cliente
     });
 }
コード例 #5
0
 public CustomerPolicyResponse CreateCustomerPolicy([FromBody] CustomerPolicyRequest customerPolicyRequest)
 {
     return(CustomerPolicyApplicationService.CreateCustomerPolicy(customerPolicyRequest));
 }