2055 lines
108 KiB
C#
2055 lines
108 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data.Entity.Validation;
|
|||
|
|
using System.Data.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Web.Http;
|
|||
|
|
using ULA.Davivienda.PrendarioModel;
|
|||
|
|
using ULA.Davivienda.PrendarioModel.Prendario;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Commons;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.CotizadorServiceLayer;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Json;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFPrendarioSeguros;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using Ultimus.Utilitarios;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFDocumentos;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Xml;
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
public class InformaAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
Crypt crypt = new Crypt();
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonSolicitud getDataModel(int _IdSolicitud, string etapa)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
JsonSolicitud resp = new JsonSolicitud();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
resp.Solicitud = (from s in db.Solicitud
|
|||
|
|
.Include(e => e.Garantia)
|
|||
|
|
.Include(e => e.Sucursal)
|
|||
|
|
.Include(e => e.DatosAprobacion)
|
|||
|
|
where s.IdSolicitud == _IdSolicitud
|
|||
|
|
select s).FirstOrDefault();
|
|||
|
|
|
|||
|
|
resp.Solicitud.DatosAprobacion = (from s in db.DatosAprobacion
|
|||
|
|
.Include(e => e.Decision)
|
|||
|
|
where s.IdSolicitud == _IdSolicitud
|
|||
|
|
select s).ToList();
|
|||
|
|
|
|||
|
|
resp.Solicitante = (from sl in db.Solicitante
|
|||
|
|
.Include(e => e.Cliente)
|
|||
|
|
.Include(e => e.TipoSolicitante)
|
|||
|
|
where sl.IdSolicitud == resp.Solicitud.IdSolicitud
|
|||
|
|
select sl).ToList();
|
|||
|
|
|
|||
|
|
Solicitud solicitud = db.Solicitud.Where(x => x.IdSolicitud == resp.Solicitud.IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
resp.EjecutivoCotizacion = (from ec in db.EjecutivoCotizacion
|
|||
|
|
where ec.IdCotizacion == solicitud.IdCotizacion
|
|||
|
|
select ec).FirstOrDefault();
|
|||
|
|
|
|||
|
|
int IdEtapa = db.Etapas.Where(x => x.DescripcionEtapa.Trim() == etapa).FirstOrDefault().IdEtapa;
|
|||
|
|
|
|||
|
|
List<HistorialDecision> ListaHistorial = (from hd in db.HistorialDecision
|
|||
|
|
.Include(x => x.Decision)
|
|||
|
|
.Include(x => x.Motivo)
|
|||
|
|
where hd.IdSolicitud == _IdSolicitud && hd.IdEtapa == IdEtapa
|
|||
|
|
select hd).ToList();
|
|||
|
|
if (ListaHistorial.FirstOrDefault() != null)
|
|||
|
|
{
|
|||
|
|
int IdHistorial = ListaHistorial.Max(q => q.IdHistorialDecision);
|
|||
|
|
|
|||
|
|
resp.HistorialDecision = (from hd in ListaHistorial
|
|||
|
|
where hd.IdHistorialDecision == IdHistorial
|
|||
|
|
select hd).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
resp.DatosCotizacion = (from c in db.Cotizacion
|
|||
|
|
.Include(e => e.Campanna)
|
|||
|
|
.Include(e => e.ProgramaCrediticio)
|
|||
|
|
.Include(e => e.AnnoVehiculo)
|
|||
|
|
.Include(e => e.Moneda)
|
|||
|
|
.Include(e => e.TipoVehiculo)
|
|||
|
|
.Include(e => e.CondicionesTasaCotizacion)
|
|||
|
|
.Include(e => e.AgenciaVehiculo)
|
|||
|
|
.Include(e => e.SubAgenciaVehiculo)
|
|||
|
|
.Include(e => e.MarcaVehiculo)
|
|||
|
|
.Include(e => e.EstiloVehiculo)
|
|||
|
|
.Include(e => e.TipoFuenteIngreso)
|
|||
|
|
.Include(e => e.UsoVehiculo)
|
|||
|
|
.Include(e => e.SegurosCotizacion)
|
|||
|
|
.Include(e => e.EjecutivoCotizacion)
|
|||
|
|
where c.IdCotizacion == resp.Solicitud.IdCotizacion
|
|||
|
|
select new JsonDatosCotizacion
|
|||
|
|
{
|
|||
|
|
IdCotizacion = c.IdCotizacion,
|
|||
|
|
Campanna = c.Campanna,
|
|||
|
|
IdCampanna = c.Campanna.IdCampanna,
|
|||
|
|
DescripcionCampanna = c.Campanna.Descripcion,
|
|||
|
|
|
|||
|
|
ProgramaCrediticio = c.ProgramaCrediticio,
|
|||
|
|
IdProgramaCrediticio = c.IdProgramaCrediticio,
|
|||
|
|
DescripcionProgramaCrediticio = c.ProgramaCrediticio.Descripcion,
|
|||
|
|
|
|||
|
|
AnnoVehiculo = c.AnnoVehiculo,
|
|||
|
|
IdAnnoVehiculo = c.AnnoVehiculo.IdAnnoVehiculo,
|
|||
|
|
DescripcionAnnoVehiculo = c.AnnoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
Moneda = c.Moneda,
|
|||
|
|
IdMoneda = c.Moneda.IdMoneda,
|
|||
|
|
DescripcionMoneda = c.Moneda.Descripcion,
|
|||
|
|
|
|||
|
|
TipoVehiculo = c.TipoVehiculo,
|
|||
|
|
IdTipoVehiculo = c.TipoVehiculo.IdTipoVehiculo,
|
|||
|
|
DescripcionTipoVehiculo = c.TipoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
CondicionesTasaCotizacion = c.CondicionesTasaCotizacion,
|
|||
|
|
|
|||
|
|
AgenciaVehiculo = c.AgenciaVehiculo,
|
|||
|
|
IdAgenciaVehiculo = c.AgenciaVehiculo.IdAgenciaVehiculo,
|
|||
|
|
DescripcionAgenciaVehiculo = c.AgenciaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
SubAgenciaVehiculo = c.SubAgenciaVehiculo,
|
|||
|
|
IdSubAgenciaVehiculo = c.SubAgenciaVehiculo.IdSubAgenciaVehiculo,
|
|||
|
|
DescripcionSubAgenciaVehiculo = c.SubAgenciaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
MarcaVehiculo = c.MarcaVehiculo,
|
|||
|
|
IdMarcaVehiculo = c.MarcaVehiculo.IdMarcaVehiculo,
|
|||
|
|
DescripcionMarcaVehiculo = c.MarcaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
EstiloVehiculo = c.EstiloVehiculo,
|
|||
|
|
IdEstiloVehiculo = c.EstiloVehiculo.IdEstiloVehiculo,
|
|||
|
|
DescripcionEstiloVehiculo = c.EstiloVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
TipoFuenteIngreso = c.TipoFuenteIngreso,
|
|||
|
|
IdFuenteIngreso = c.TipoFuenteIngreso.IdFuenteIngreso,
|
|||
|
|
DescripcionTipoFuenteIngreso = c.TipoFuenteIngreso.Descripcion,
|
|||
|
|
|
|||
|
|
UsoVehiculo = c.UsoVehiculo,
|
|||
|
|
IdUsoVehiculo = c.UsoVehiculo.IdUsoVehiculo,
|
|||
|
|
DescripcionUsoVehiculo = c.UsoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
EsColaborador = c.EsColaborador,
|
|||
|
|
PorcComision = c.PorcComision,
|
|||
|
|
PorcPrimaMinima = c.PorcPrimaMinima,
|
|||
|
|
PeriodoMesesCredito = c.PeriodoMesesCredito,
|
|||
|
|
PeriodoMesesGracia = c.PeriodoMesesGracia,
|
|||
|
|
ValorVehiculo = c.ValorVehiculo,
|
|||
|
|
TipoCambio = c.TipoCambio,
|
|||
|
|
PorcPrima = c.PorcPrima,
|
|||
|
|
MontoPrima = c.MontoPrima,
|
|||
|
|
MontoComision = c.MontoComision,
|
|||
|
|
PorcIngresoMinReq = c.PorcIngresoMinReq,
|
|||
|
|
IngresoMinReqCol = c.IngresoMinReqCol,
|
|||
|
|
IngresoMInReqDol = c.IngresoMInReqDol,
|
|||
|
|
MontoPrestamo = c.MontoPrestamo,
|
|||
|
|
MontoDesembolso = c.MontoDesembolso,
|
|||
|
|
FeCotiza = c.FeCotiza,
|
|||
|
|
|
|||
|
|
TipoIdentificacion = c.TipoIdentificacion,
|
|||
|
|
IdTipoIdentificacion = c.TipoIdentificacion.IdTipoIdentificacion,
|
|||
|
|
DescripcionTipoIdentificacion = c.TipoIdentificacion.Descripcion,
|
|||
|
|
|
|||
|
|
Identificacion = c.Identificacion,
|
|||
|
|
PrimerNombre = c.PrimerNombre,
|
|||
|
|
SegundoNombre = c.SegundoNombre,
|
|||
|
|
PrimerApellido = c.PrimerApellido,
|
|||
|
|
SegundoApellido = c.SegundoApellido,
|
|||
|
|
Email = c.Email,
|
|||
|
|
EstadoCotiza = c.EstadoCotiza,
|
|||
|
|
|
|||
|
|
|
|||
|
|
SegurosCotizacion = c.SegurosCotizacion,
|
|||
|
|
|
|||
|
|
EjecutivoCotizacion = c.EjecutivoCotizacion,
|
|||
|
|
AplicaPolizaVehiculoGratis = c.AplicaPolizaVehiculoGratis,
|
|||
|
|
|
|||
|
|
}).ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (Solicitante z in resp.Solicitante)
|
|||
|
|
{
|
|||
|
|
z.Cliente = (from s in db.Cliente
|
|||
|
|
.Include(e => e.Genero)
|
|||
|
|
.Include(e => e.TipoIdentificacion)
|
|||
|
|
.Include(e => e.Profesion)
|
|||
|
|
.Include(e => e.Nacionalidad)
|
|||
|
|
where s.IdCliente == z.IdCliente
|
|||
|
|
select s).FirstOrDefault();
|
|||
|
|
|
|||
|
|
z.Cliente.DireccionCliente.Add((from s in db.DireccionCliente
|
|||
|
|
.Include(e => e.Provincia)
|
|||
|
|
.Include(e => e.Distrito)
|
|||
|
|
.Include(e => e.Distrito.Canton)
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoDireccion.Trim().Equals("DM")
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
|
|||
|
|
z.Cliente.TelefonoCliente.Add((from s in db.TelefonoCliente
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoTelefono.Trim().Equals("DM")
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
|
|||
|
|
|
|||
|
|
z.Cliente.EmailCliente.Add((from s in db.EmailCliente
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoEmail == 1
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (Garantia g in resp.Solicitud.Garantia)
|
|||
|
|
{
|
|||
|
|
g.TipoCombustible = db.TipoCombustible.Where(e => e.IdTipoCombustible == g.IdTipoCombustible).FirstOrDefault();
|
|||
|
|
g.TipoTraccion = db.TipoTraccion.Where(e => e.IdTipoTraccion == g.IdTipoTraccion).FirstOrDefault();
|
|||
|
|
g.TipoTransmision = db.TipoTransmision.Where(e => e.IdTipoTransmision == g.IdTipoTransmision).FirstOrDefault();
|
|||
|
|
g.CategoriaVehiculo = db.CategoriaVehiculo.Where(e => e.IdCategoriaVehiculo == g.IdCategoriaVehiculo).FirstOrDefault();
|
|||
|
|
g.CarroceriaVehiculo = db.CarroceriaVehiculo.Where(e => e.IdCarroceriaVehiculo == g.IdCarroceriaVehiculo).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (JsonDatosCotizacion x in resp.DatosCotizacion)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
foreach (SegurosCotizacion y in x.SegurosCotizacion)
|
|||
|
|
{
|
|||
|
|
y.RubroSeguro = db.RubroSeguro.Where(e => e.IdRubroSeguro == y.IdRubroSeguro).FirstOrDefault();
|
|||
|
|
y.RubroSeguro.Aseguradora = db.Aseguradora.Where(e => e.IdAseguradora == y.RubroSeguro.IdAseguradora).FirstOrDefault();
|
|||
|
|
y.RubroSeguro.TipoRubroSeguro = db.TipoRubroSeguro.Where(e => e.IdTipoRubroSeguro == y.RubroSeguro.IdTipoRubroSeguro).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (CondicionesTasaCotizacion y in x.CondicionesTasaCotizacion)
|
|||
|
|
{
|
|||
|
|
y.TipoTasa = db.TipoTasa.Where(e => e.IdTipoTasa == y.IdTipoTasa).FirstOrDefault();
|
|||
|
|
y.TipoTasaReferencia = db.TipoTasaReferencia.Where(e => e.IdTipoTasaReferencia == y.IdTipoTasaReferencia).FirstOrDefault();
|
|||
|
|
y.PeriodoReajuste = db.PeriodoReajuste.Where(e => e.IdPeriodoReajuste == y.IdPeriodoReajuste).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = ex.Message;
|
|||
|
|
}
|
|||
|
|
return resp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region saveDataModel
|
|||
|
|
[HttpPost]
|
|||
|
|
public string saveDataModel([FromBody] JsonSolicitud _model)
|
|||
|
|
{
|
|||
|
|
int? Next_id = null;
|
|||
|
|
int idActual = 0;
|
|||
|
|
bool bInsert = false;
|
|||
|
|
Garantia _modelGarantiaInsUpdate = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
#region Garantia
|
|||
|
|
_modelGarantiaInsUpdate = db.Garantia.Where(s => s.IdSolicitud == _model.Solicitud.IdSolicitud).FirstOrDefault();
|
|||
|
|
if (_modelGarantiaInsUpdate == null)
|
|||
|
|
{
|
|||
|
|
bInsert = true;
|
|||
|
|
_modelGarantiaInsUpdate = new Garantia();
|
|||
|
|
}
|
|||
|
|
_modelGarantiaInsUpdate.Chasis = _model.Solicitud.Garantia.First().Chasis;
|
|||
|
|
_modelGarantiaInsUpdate.Motor = _model.Solicitud.Garantia.First().Motor;
|
|||
|
|
_modelGarantiaInsUpdate.Placa = _model.Solicitud.Garantia.First().Placa;
|
|||
|
|
_modelGarantiaInsUpdate.Color = _model.Solicitud.Garantia.First().Color;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoTraccion = _model.Solicitud.Garantia.First().IdTipoTraccion;
|
|||
|
|
_modelGarantiaInsUpdate.PesoNeto = _model.Solicitud.Garantia.First().PesoNeto;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoTransmision = _model.Solicitud.Garantia.First().IdTipoTransmision;
|
|||
|
|
_modelGarantiaInsUpdate.Cilindrada = _model.Solicitud.Garantia.First().Cilindrada;
|
|||
|
|
_modelGarantiaInsUpdate.NumCilindros = _model.Solicitud.Garantia.First().NumCilindros;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoCombustible = _model.Solicitud.Garantia.First().IdTipoCombustible;
|
|||
|
|
_modelGarantiaInsUpdate.Capacidad = _model.Solicitud.Garantia.First().Capacidad;
|
|||
|
|
_modelGarantiaInsUpdate.InscritoANombre = string.IsNullOrEmpty(_model.Solicitud.Garantia.First().InscritoANombre) ? _model.Solicitud.Garantia.First().InscritoANombre : _model.Solicitud.Garantia.First().InscritoANombre.ToUpper();
|
|||
|
|
_modelGarantiaInsUpdate.IdCategoriaVehiculo = _model.Solicitud.Garantia.First().IdCategoriaVehiculo;
|
|||
|
|
_modelGarantiaInsUpdate.IdCarroceriaVehiculo = _model.Solicitud.Garantia.First().IdCarroceriaVehiculo;
|
|||
|
|
|
|||
|
|
if (_model.Solicitud.Garantia.First().ConductorHabitual_IdTipoIdentificacion == 0)
|
|||
|
|
{
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_IdTipoIdentificacion = null;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Identificacion = null;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Nombre = null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_IdTipoIdentificacion = _model.Solicitud.Garantia.First().ConductorHabitual_IdTipoIdentificacion;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Identificacion = _model.Solicitud.Garantia.First().ConductorHabitual_Identificacion;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Nombre = _model.Solicitud.Garantia.First().ConductorHabitual_Nombre;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (bInsert)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Next_id = db.Garantia.Max(t => t.IdGarantia);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
Next_id = (int?)null;
|
|||
|
|
}
|
|||
|
|
idActual = (Next_id == null) ? 0 : Convert.ToInt32(Next_id);
|
|||
|
|
idActual++;
|
|||
|
|
_modelGarantiaInsUpdate.IdGarantia = idActual;
|
|||
|
|
_modelGarantiaInsUpdate.IdSolicitud = _model.Solicitud.IdSolicitud;
|
|||
|
|
db.Garantia.Add(_modelGarantiaInsUpdate);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(_modelGarantiaInsUpdate).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Asegurado
|
|||
|
|
//****************************************
|
|||
|
|
//1- Obtener Informacion
|
|||
|
|
//****************************************
|
|||
|
|
//Obtiene el nuevo solicitante de tipo asegurado que viene como del formulario
|
|||
|
|
Solicitante _modelSolicitante = _model.Solicitud.Solicitante.Where(x => x.IdTipoSolicitante == 5
|
|||
|
|
|| x.IdTipoSolicitante == 6
|
|||
|
|
|| x.IdTipoSolicitante == 7).FirstOrDefault();
|
|||
|
|
//****************************************
|
|||
|
|
//2 - Crear Cliente
|
|||
|
|
//****************************************
|
|||
|
|
//Si el solicitante es de tipo "Otro Asegurado" crea/actualiza el deudor
|
|||
|
|
if (_modelSolicitante != null)
|
|||
|
|
{
|
|||
|
|
switch (_modelSolicitante.IdTipoSolicitante)
|
|||
|
|
{
|
|||
|
|
case 7: //Asegurado - Otro
|
|||
|
|
_modelSolicitante.IdCliente = saveCliente(db, _modelSolicitante.Cliente);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
//****************************************
|
|||
|
|
//3 - Limpiar Anteriores
|
|||
|
|
//****************************************
|
|||
|
|
//Obtiene los participantes de la solicitud que estan registrados como asegurados
|
|||
|
|
//pero que son diferentes al asegurado actual y los elimina
|
|||
|
|
List<Solicitante> listSolicitante = db.Solicitante.Where(x => (x.IdTipoSolicitante == (int)EnumTipoSolicitante.AseguradoDeudor
|
|||
|
|
|| x.IdTipoSolicitante == (int)EnumTipoSolicitante.AseguradoCodeudor
|
|||
|
|
|| x.IdTipoSolicitante == (int)EnumTipoSolicitante.AseguradoOtro)
|
|||
|
|
&& x.IdSolicitud == _modelSolicitante.IdSolicitud
|
|||
|
|
&& x.IdCliente != _modelSolicitante.IdCliente).ToList();
|
|||
|
|
foreach (Solicitante _Solicitante in listSolicitante)
|
|||
|
|
{
|
|||
|
|
deleteSolicitante(db, _Solicitante);
|
|||
|
|
//Si es de tipo de Participante "Otro Asegurado"
|
|||
|
|
//elimina el registro de la persona de la tabla de clientes
|
|||
|
|
if (_Solicitante.IdTipoSolicitante == (int)EnumTipoSolicitante.AseguradoOtro)
|
|||
|
|
{
|
|||
|
|
deleteCliente(db, _Solicitante.IdCliente);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//****************************************
|
|||
|
|
//4 - Agregar Participante
|
|||
|
|
//****************************************
|
|||
|
|
//Registra el tipo de solicitante actual como Asegurado de la IdSolicitud
|
|||
|
|
saveSolicitante(db, _modelSolicitante);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
Cliente _modelClienteAsegurado = db.Cliente.Where(s => s.IdCliente == _modelSolicitante.IdCliente).FirstOrDefault();
|
|||
|
|
Garantia _modelGarantia = db.Garantia.Where(s => s.IdSolicitud == _modelSolicitante.IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (_modelClienteAsegurado != null && _modelGarantia != null)
|
|||
|
|
{
|
|||
|
|
_modelGarantia.InscritoANombre = ((string.IsNullOrEmpty(_modelClienteAsegurado.PrimerNombre) ? "" : " " + _modelClienteAsegurado.PrimerNombre.Trim()) + (string.IsNullOrEmpty(_modelClienteAsegurado.SegundoNombre) ? "" : " " + _modelClienteAsegurado.SegundoNombre.Trim()) + (string.IsNullOrEmpty(_modelClienteAsegurado.PrimerApellido) ? "" : " " + _modelClienteAsegurado.PrimerApellido.Trim()) + (string.IsNullOrEmpty(_modelClienteAsegurado.SegundoApellido) ? "" : " " + _modelClienteAsegurado.SegundoApellido.Trim())).ToUpper();
|
|||
|
|
db.Entry(_modelGarantia).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region EjecutivoCotizacion
|
|||
|
|
|
|||
|
|
Solicitud solicitud = db.Solicitud.Where(x => x.IdSolicitud == _model.Solicitud.IdSolicitud).FirstOrDefault();
|
|||
|
|
EjecutivoCotizacion EjecutivoCotizacion = db.EjecutivoCotizacion.Where(x => x.IdCotizacion == solicitud.IdCotizacion).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (EjecutivoCotizacion != null)
|
|||
|
|
{
|
|||
|
|
EjecutivoCotizacion.EjecutivoAgenciaNombre = _model.EjecutivoCotizacion.EjecutivoAgenciaNombre;
|
|||
|
|
EjecutivoCotizacion.EjecutivoAgenciaEmail = _model.EjecutivoCotizacion.EjecutivoAgenciaEmail;
|
|||
|
|
db.Entry(EjecutivoCotizacion).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Exception Exp = ex.InnerException;
|
|||
|
|
while (Exp != null)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", Exp);
|
|||
|
|
Exp = Exp.InnerException;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex.StackTrace);
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
}
|
|||
|
|
return TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private int saveCliente(PrendarioContext db, Cliente _modelCliente)
|
|||
|
|
{
|
|||
|
|
int? Next_id = null;
|
|||
|
|
int idActual = 0;
|
|||
|
|
bool bInsert = false;
|
|||
|
|
Cliente _modelClienteInsUpdate = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_modelClienteInsUpdate = db.Cliente
|
|||
|
|
.Include("DireccionCliente")
|
|||
|
|
.Include("TelefonoCliente")
|
|||
|
|
.Include("EmailCliente").Where(s => s.IdCliente == _modelCliente.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (_modelClienteInsUpdate == null)
|
|||
|
|
{
|
|||
|
|
bInsert = true;
|
|||
|
|
_modelClienteInsUpdate = new Cliente();
|
|||
|
|
}
|
|||
|
|
_modelClienteInsUpdate.IdTipoIdentificacion = _modelCliente.IdTipoIdentificacion;
|
|||
|
|
_modelClienteInsUpdate.Identificacion = _modelCliente.Identificacion;
|
|||
|
|
_modelClienteInsUpdate.PrimerNombre = string.IsNullOrEmpty(_modelCliente.PrimerNombre) ? _modelCliente.PrimerNombre : _modelCliente.PrimerNombre.ToUpper();
|
|||
|
|
_modelClienteInsUpdate.SegundoNombre = string.IsNullOrEmpty(_modelCliente.SegundoNombre) ? _modelCliente.SegundoNombre : _modelCliente.SegundoNombre.ToUpper();
|
|||
|
|
_modelClienteInsUpdate.PrimerApellido = string.IsNullOrEmpty(_modelCliente.PrimerApellido) ? _modelCliente.PrimerApellido : _modelCliente.PrimerApellido.ToUpper();
|
|||
|
|
_modelClienteInsUpdate.SegundoApellido = string.IsNullOrEmpty(_modelCliente.SegundoApellido) ? _modelCliente.SegundoApellido : _modelCliente.SegundoApellido.ToUpper();
|
|||
|
|
_modelClienteInsUpdate.FeNacimiento = _modelCliente.FeNacimiento;
|
|||
|
|
_modelClienteInsUpdate.IdGenero = _modelCliente.IdGenero;
|
|||
|
|
_modelClienteInsUpdate.IdProfesion = _modelCliente.IdProfesion;
|
|||
|
|
_modelClienteInsUpdate.IdPaisNacimiento = _modelCliente.IdPaisNacimiento;
|
|||
|
|
_modelClienteInsUpdate.IdNacionalidad = _modelCliente.IdNacionalidad;
|
|||
|
|
|
|||
|
|
if (_modelClienteInsUpdate.DireccionCliente.Count() == 0)
|
|||
|
|
{
|
|||
|
|
_modelCliente.DireccionCliente.FirstOrDefault().IdDireccion = 1;
|
|||
|
|
_modelClienteInsUpdate.DireccionCliente = _modelCliente.DireccionCliente;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
DireccionCliente aux = _modelClienteInsUpdate.DireccionCliente.Where(e => e.IdTipoDireccion.Trim().Equals("DM")).FirstOrDefault();
|
|||
|
|
aux.IdProvincia = _modelCliente.DireccionCliente.FirstOrDefault().IdProvincia;
|
|||
|
|
aux.IdCanton = _modelCliente.DireccionCliente.FirstOrDefault().IdCanton;
|
|||
|
|
aux.IdDistrito = _modelCliente.DireccionCliente.FirstOrDefault().IdDistrito;
|
|||
|
|
aux.DirExacta = _modelCliente.DireccionCliente.FirstOrDefault().DirExacta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_modelClienteInsUpdate.TelefonoCliente.Count() == 0)
|
|||
|
|
{
|
|||
|
|
_modelCliente.TelefonoCliente.FirstOrDefault().IdTelefono = 1;
|
|||
|
|
_modelClienteInsUpdate.TelefonoCliente = _modelCliente.TelefonoCliente;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TelefonoCliente auxTelefono = _modelClienteInsUpdate.TelefonoCliente.Where(e => e.IdTipoTelefono.Trim().Equals("DM")).FirstOrDefault();
|
|||
|
|
auxTelefono.Telefono = _modelCliente.TelefonoCliente.FirstOrDefault().Telefono;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_modelClienteInsUpdate.EmailCliente.Count() == 0)
|
|||
|
|
{
|
|||
|
|
_modelCliente.EmailCliente.FirstOrDefault().IdEmail = 1;
|
|||
|
|
_modelClienteInsUpdate.EmailCliente = _modelCliente.EmailCliente;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
EmailCliente auxEmail = _modelClienteInsUpdate.EmailCliente.Where(e => e.IdTipoEmail == 1).FirstOrDefault();
|
|||
|
|
auxEmail.Email = _modelCliente.EmailCliente.FirstOrDefault().Email;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (bInsert)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Next_id = db.Cliente.Max(t => t.IdCliente);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
Next_id = (int?)null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
idActual = (Next_id == null) ? 0 : Convert.ToInt32(Next_id);
|
|||
|
|
idActual++;
|
|||
|
|
_modelClienteInsUpdate.IdCliente = idActual;
|
|||
|
|
db.Cliente.Add(_modelClienteInsUpdate);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
idActual = _modelClienteInsUpdate.IdCliente;
|
|||
|
|
db.Entry(_modelClienteInsUpdate).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return idActual;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void deleteCliente(PrendarioContext db, int _idCliente)
|
|||
|
|
{
|
|||
|
|
Cliente _modelClienteDelete = null;
|
|||
|
|
List<TelefonoCliente> _modelTelefonoClienteDelete = null;
|
|||
|
|
List<DireccionCliente> _modelDireccionClienteDelete = null;
|
|||
|
|
List<EmailCliente> _modelEmailClienteDelete = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//Telefono
|
|||
|
|
_modelTelefonoClienteDelete = db.TelefonoCliente.Where(x => x.IdCliente == _idCliente).ToList();
|
|||
|
|
if (_modelTelefonoClienteDelete != null)
|
|||
|
|
db.TelefonoCliente.RemoveRange(_modelTelefonoClienteDelete);
|
|||
|
|
|
|||
|
|
//Direccion
|
|||
|
|
_modelDireccionClienteDelete = db.DireccionCliente.Where(x => x.IdCliente == _idCliente).ToList();
|
|||
|
|
if (_modelDireccionClienteDelete != null)
|
|||
|
|
db.DireccionCliente.RemoveRange(_modelDireccionClienteDelete);
|
|||
|
|
|
|||
|
|
//Email
|
|||
|
|
_modelEmailClienteDelete = db.EmailCliente.Where(x => x.IdCliente == _idCliente).ToList();
|
|||
|
|
if (_modelEmailClienteDelete != null)
|
|||
|
|
db.EmailCliente.RemoveRange(_modelEmailClienteDelete);
|
|||
|
|
|
|||
|
|
//Cliente
|
|||
|
|
_modelClienteDelete = db.Cliente.Where(s => s.IdCliente == _idCliente).FirstOrDefault();
|
|||
|
|
if (_modelClienteDelete != null)
|
|||
|
|
db.Cliente.Remove(_modelClienteDelete);
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void saveSolicitante(PrendarioContext db, Solicitante _modelSolicitante)
|
|||
|
|
{
|
|||
|
|
bool bInsert = false;
|
|||
|
|
Solicitante _modelSolicitanteInsUpdate = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_modelSolicitanteInsUpdate = db.Solicitante.Where(s => s.IdSolicitud == _modelSolicitante.IdSolicitud
|
|||
|
|
&& s.IdCliente == _modelSolicitante.IdCliente
|
|||
|
|
&& s.IdTipoSolicitante == _modelSolicitante.IdTipoSolicitante).FirstOrDefault();
|
|||
|
|
if (_modelSolicitanteInsUpdate == null)
|
|||
|
|
{
|
|||
|
|
bInsert = true;
|
|||
|
|
_modelSolicitanteInsUpdate = new Solicitante();
|
|||
|
|
}
|
|||
|
|
_modelSolicitanteInsUpdate.IdSolicitud = _modelSolicitante.IdSolicitud;
|
|||
|
|
_modelSolicitanteInsUpdate.IdCliente = _modelSolicitante.IdCliente;
|
|||
|
|
_modelSolicitanteInsUpdate.IdTipoSolicitante = _modelSolicitante.IdTipoSolicitante;
|
|||
|
|
_modelSolicitanteInsUpdate.EsPrincipal = _modelSolicitante.EsPrincipal;
|
|||
|
|
if (bInsert)
|
|||
|
|
{
|
|||
|
|
db.Solicitante.Add(_modelSolicitanteInsUpdate);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(_modelSolicitanteInsUpdate).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void deleteSolicitante(PrendarioContext db, Solicitante _modelSolicitante)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (_modelSolicitante != null)
|
|||
|
|
db.Solicitante.Remove(_modelSolicitante);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Enviar
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonResponseBase Enviar([FromBody] JsonEnviarInforma _model)
|
|||
|
|
{
|
|||
|
|
JsonResponseBase ret = new JsonResponseBase();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
bool envioCorreo = false;
|
|||
|
|
string emailCorreo = string.Empty;
|
|||
|
|
|
|||
|
|
//Decision Ir a Seguros
|
|||
|
|
if (int.Parse(_model.IdDecision) == EnumDecision.IrASeguros)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
#region ValidaBeneficiarios
|
|||
|
|
|
|||
|
|
SegurosCotizacion segAuto = db.SegurosCotizacion.Include(s => s.RubroSeguro).Where(s => s.IdCotizacion == _model.IdCotizacion && s.RubroSeguro.IdTipoRubroSeguro == 3).FirstOrDefault();
|
|||
|
|
|
|||
|
|
//Si el rubro de seguro existe
|
|||
|
|
if (segAuto != null && _model.IdAseguradora == EnumAseguradora.INS)
|
|||
|
|
{
|
|||
|
|
decimal decSumaPorcentaje = 0;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
decSumaPorcentaje = db.BeneficiarioSeguro.Where(e => e.IdSolicitud == _model.IdSolicitud).Sum(e => e.Porcentaje).Value;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
decSumaPorcentaje = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (decSumaPorcentaje > 100)
|
|||
|
|
{
|
|||
|
|
ret.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
ret.DescripcionRespuesta = "Estimado usuario, la suma de porcentajes registrados para beneficiarios supera el 100%. Por favor verifique.";
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
else if (decSumaPorcentaje < 100)
|
|||
|
|
{
|
|||
|
|
ret.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
ret.DescripcionRespuesta = "Estimado usuario, es requerido que la suma de porcentajes registrados para beneficiarios complete el 100%. Por favor verifique.";
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
///////****************************************
|
|||
|
|
//////CUIDADO CON ESTE CODIGO, VALIDAR BIEN
|
|||
|
|
///////****************************************
|
|||
|
|
#region Beneficiarios
|
|||
|
|
SegurosCotizacion seguroVida = (from q in db.SegurosCotizacion.Include(q => q.RubroSeguro)
|
|||
|
|
where q.IdCotizacion == _model.IdCotizacion
|
|||
|
|
&& q.RubroSeguro.IdTipoRubroSeguro == (int)EnumTipoRubroSeguro.Vida
|
|||
|
|
select q).FirstOrDefault();
|
|||
|
|
if (seguroVida != null)
|
|||
|
|
{
|
|||
|
|
List<BeneficiarioSeguro> beneficiarios = db.BeneficiarioSeguro.Where(q => q.IdSolicitud == _model.IdSolicitud && q.RubroSeguro.IdTipoRubroSeguro == (int)EnumTipoRubroSeguro.Vida).ToList();
|
|||
|
|
if (beneficiarios.Count == 0)
|
|||
|
|
{
|
|||
|
|
ret.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
ret.DescripcionRespuesta = "Se deben llenar los beneficiarios";
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
decimal? total = beneficiarios.Sum(q => q.Porcentaje);
|
|||
|
|
if (total.HasValue && total.Value != 100)
|
|||
|
|
{
|
|||
|
|
ret.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
ret.DescripcionRespuesta = "Se debe asignar un 100% entre los beneficiarios";
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
///////****************************************
|
|||
|
|
///////FIN
|
|||
|
|
///////****************************************
|
|||
|
|
|
|||
|
|
#region CrearActualizarCliente
|
|||
|
|
Solicitud solicitud = db.Solicitud
|
|||
|
|
.Include(e => e.Solicitante)
|
|||
|
|
.Where(s => s.IdSolicitud == _model.IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
string _UserIdOnly = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_UserIdOnly = _model.UserId.Split(new char[] { '/' })[1];
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
_UserIdOnly = _model.UserId.Split(new char[] { '/' })[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (var x in solicitud.Solicitante)
|
|||
|
|
{
|
|||
|
|
if (x.IdTipoSolicitante == 1)
|
|||
|
|
{
|
|||
|
|
var respDeudor = ActualizarDatosMIS(_model.IdSolicitud, x.IdTipoSolicitante, _model.TipoCambio, _model.Incident, _UserIdOnly);
|
|||
|
|
if (respDeudor.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(respDeudor.DescripcionRespuesta);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (x.IdTipoSolicitante == 2)
|
|||
|
|
{
|
|||
|
|
var respCodeudor = ActualizarDatosMIS(_model.IdSolicitud, x.IdTipoSolicitante, _model.TipoCambio, _model.Incident, _UserIdOnly);
|
|||
|
|
if (respCodeudor.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(respCodeudor.DescripcionRespuesta);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region EnvioCorreoNotificacionAprobacion
|
|||
|
|
|
|||
|
|
bool bEjecuta = false;
|
|||
|
|
if (bEjecuta == true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Cliente client = null;
|
|||
|
|
EmailCliente emailDeudor = null;
|
|||
|
|
EjecutivoCotizacion eje = null;
|
|||
|
|
|
|||
|
|
if (_model.EnviarNotificacionAprobacionCliente)
|
|||
|
|
{
|
|||
|
|
//Obtiene la solicitud
|
|||
|
|
Solicitud sol = db.Solicitud.Include(y => y.Solicitante).Where(y => y.IdSolicitud == _model.IdSolicitud).FirstOrDefault();
|
|||
|
|
|
|||
|
|
//Obtiene el Cliente
|
|||
|
|
int? IdDeudor = sol.Solicitante.Where(z => z.IdTipoSolicitante == 1).Select(z => z.IdCliente).FirstOrDefault();
|
|||
|
|
client = db.Cliente.Include(q => q.EmailCliente)
|
|||
|
|
.Where(q => q.IdCliente == IdDeudor).FirstOrDefault();
|
|||
|
|
|
|||
|
|
//Obtiene el Email Personal
|
|||
|
|
emailDeudor = client.EmailCliente.Where(t => t.IdTipoEmail == 1).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (emailDeudor == null)
|
|||
|
|
{
|
|||
|
|
//Obtiene el Email Laboral
|
|||
|
|
emailDeudor = client.EmailCliente.Where(t => t.IdTipoEmail == 2).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (emailDeudor == null)
|
|||
|
|
{
|
|||
|
|
//Obtiene el Email de la cotizacion
|
|||
|
|
emailDeudor = db.Cotizacion.Where(j => j.IdCotizacion == _model.IdCotizacion).Select(p => new EmailCliente() { Email = p.Email }).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (_model.EnviarNotificacionAprobacionVendedor)
|
|||
|
|
eje = db.EjecutivoCotizacion.Where(q => q.IdCotizacion == _model.IdCotizacion).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (client != null || eje != null)
|
|||
|
|
{
|
|||
|
|
DocumentosAPIController api = new DocumentosAPIController();
|
|||
|
|
JsonDocumentoResponse res = api.ImprimirCartaAprobacion(_model.IdSolicitud);
|
|||
|
|
if (res.CodigoRespuesta == TipoCodigoRespuesta.EXITOSO.ToString())
|
|||
|
|
{
|
|||
|
|
string Subject = Convert.ToString(ConfigurationManager.AppSettings["NotificaciónAprobaciónCliente.Subject"]);
|
|||
|
|
string Body = Convert.ToString(ConfigurationManager.AppSettings["NotificaciónAprobaciónCliente.Body"]);
|
|||
|
|
bool IsBodyHtml = Convert.ToBoolean(ConfigurationManager.AppSettings["NotificaciónAprobaciónCliente.IsBodyHtml"]);
|
|||
|
|
List<string> Attach = new List<string>() { res.path };
|
|||
|
|
|
|||
|
|
List<string> MailTo = new List<string>();
|
|||
|
|
|
|||
|
|
//Email del Cliente
|
|||
|
|
if (emailDeudor != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(emailDeudor.Email)) { MailTo.Add(emailDeudor.Email); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Email del Ejecutivo
|
|||
|
|
if (eje != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(eje.EjecutivoAgenciaEmail)) { MailTo.Add(eje.EjecutivoAgenciaEmail); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
EmailManager em = new EmailManager();
|
|||
|
|
em.Send(Body, IsBodyHtml, Subject, Attach, MailTo);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ret.CodigoRespuesta = res.CodigoRespuesta;
|
|||
|
|
ret.DescripcionRespuesta = res.DescripcionRespuesta;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GlobalAPIController global = new GlobalAPIController();
|
|||
|
|
ret = global.Enviar(_model);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
ret.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Consulta
|
|||
|
|
private JsonCrearOperacion Consulta(int id, int tipocliente)
|
|||
|
|
{
|
|||
|
|
JsonCrearOperacion respuesta = new JsonCrearOperacion();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta.Solicitud = (from s in db.Solicitud
|
|||
|
|
.Include(e => e.Cotizacion)
|
|||
|
|
.Include(e => e.Solicitante)
|
|||
|
|
where s.IdSolicitud == id
|
|||
|
|
select s).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (respuesta.Solicitud.Solicitante.FirstOrDefault() != null)
|
|||
|
|
{
|
|||
|
|
foreach (var s in respuesta.Solicitud.Solicitante)
|
|||
|
|
{
|
|||
|
|
if (s.IdTipoSolicitante == tipocliente)
|
|||
|
|
{
|
|||
|
|
s.Cliente = db.Cliente.Where(x => x.IdCliente == s.IdCliente).FirstOrDefault();
|
|||
|
|
s.Cliente.InformacionLaboralCliente = db.InformacionLaboralCliente.Where(x => x.IdCliente == s.IdCliente).ToList();
|
|||
|
|
s.Cliente.TipoIdentificacion = db.TipoIdentificacion.Where(x => x.IdTipoIdentificacion == s.Cliente.IdTipoIdentificacion).FirstOrDefault();
|
|||
|
|
s.Cliente.TelefonoCliente = db.TelefonoCliente.Where(x => x.IdCliente == s.IdCliente).ToList();
|
|||
|
|
s.Cliente.EmailCliente = db.EmailCliente.Where(x => x.IdCliente == s.IdCliente).ToList();
|
|||
|
|
s.Cliente.InformacionIngresosCliente = db.InformacionIngresosCliente.Where(x => x.IdCliente == s.IdCliente).FirstOrDefault();
|
|||
|
|
s.Cliente.DireccionCliente = db.DireccionCliente.Where(x => x.IdCliente == s.IdCliente).ToList();
|
|||
|
|
s.Cliente.CondicionVivienda = db.CondicionVivienda.Where(x => x.IdCondicionVivienda == s.Cliente.IdCondicionVivienda).FirstOrDefault();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (respuesta.Solicitud.Cotizacion != null)
|
|||
|
|
{
|
|||
|
|
respuesta.Solicitud.Cotizacion.EjecutivoCotizacion = db.EjecutivoCotizacion.Where(x => x.IdCotizacion == respuesta.Solicitud.IdCotizacion).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ActualizarDatosMIS
|
|||
|
|
|
|||
|
|
|
|||
|
|
public BaseJsonMetadata ActualizarDatosMIS(int NoSolicitud, int TipoCliente, int TipoCambio, int Incident, string UserID)
|
|||
|
|
{
|
|||
|
|
XmlDocument xmlDoc = null;
|
|||
|
|
XmlDocument xmlResp = null;
|
|||
|
|
XmlNode nodo_principal = null;
|
|||
|
|
string nodo_error = null;
|
|||
|
|
BaseJsonMetadata respuesta = new BaseJsonMetadata();
|
|||
|
|
string sResultXmlInfoCliente = string.Empty;
|
|||
|
|
string PasswordCobis = "banex456";
|
|||
|
|
|
|||
|
|
WCFActualizaCliente.ActualizaDatosMISResponse resp = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "1" + TipoCliente.ToString());
|
|||
|
|
|
|||
|
|
xmlDoc = new XmlDocument();
|
|||
|
|
xmlResp = new XmlDocument();
|
|||
|
|
|
|||
|
|
JsonCrearOperacion consulta = Consulta(NoSolicitud, TipoCliente);
|
|||
|
|
Cliente cliente = new Cliente();
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "2" + TipoCliente.ToString());
|
|||
|
|
|
|||
|
|
foreach (var x in consulta.Solicitud.Solicitante)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "3" + TipoCliente.ToString());
|
|||
|
|
if (x.IdTipoSolicitante == TipoCliente)
|
|||
|
|
{
|
|||
|
|
cliente = x.Cliente;
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "4" + TipoCliente.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "5" + TipoCliente.ToString());
|
|||
|
|
|
|||
|
|
//********************************************************
|
|||
|
|
//Solo invoca el servicio si el cliente es nuevo
|
|||
|
|
//********************************************************
|
|||
|
|
if (!string.IsNullOrEmpty(cliente.TipoCliente))
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "6" + TipoCliente.ToString());
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrWhiteSpace(cliente.Ente))
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "7" + TipoCliente.ToString());
|
|||
|
|
|
|||
|
|
sResultXmlInfoCliente = armarXMLSoliciante(NoSolicitud, TipoCliente, TipoCambio, Incident, consulta);
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "8" + sResultXmlInfoCliente);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
xmlDoc.LoadXml(sResultXmlInfoCliente);
|
|||
|
|
|
|||
|
|
using (WCFActualizaCliente.ActualizaClienteClient ws = new WCFActualizaCliente.ActualizaClienteClient())
|
|||
|
|
{
|
|||
|
|
resp = ws.ActualizarDatosMIS(UserID, PasswordCobis, xmlDoc.OuterXml);
|
|||
|
|
|
|||
|
|
if (resp.resultado != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (resp.errCode == "99")
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//resp = new WCFActualizaCliente.ActualizaDatosMISResponse();
|
|||
|
|
//resp.resultado = "<?xml version='1.0'?><Resultado><Solicitante><co_ente>630423</co_ente><Riesgo>OK</Riesgo><Direcciones><Direccion><co_direccion>1</co_direccion><co_tipo_direccion>DM</co_tipo_direccion><Telefonos><Telefono><co_secuencial>1</co_secuencial><co_tipo>1</co_tipo></Telefono><Telefono><co_secuencial>2</co_secuencial><co_tipo>4</co_tipo></Telefono><Telefono><co_secuencial>2</co_secuencial><co_tipo>5</co_tipo></Telefono></Telefonos></Direccion><Direccion><co_direccion>2</co_direccion><co_tipo_direccion>DC</co_tipo_direccion><Telefonos><Telefono><co_secuencial>1</co_secuencial><co_tipo>2</co_tipo></Telefono><Telefono><co_secuencial></co_secuencial><co_tipo>7</co_tipo></Telefono></Telefonos></Direccion></Direcciones><ReferenciasPersonales /><FuentesIngreso><FuenteIngreso><co_empleo>1</co_empleo></FuenteIngreso></FuentesIngreso><Emails><Email><co_email>2</co_email><co_tipo_email>PERSONAL</co_tipo_email></Email></Emails><CrearCategoria><CategoriaCreada>SI</CategoriaCreada></CrearCategoria></Solicitante></Resultado>";
|
|||
|
|
|
|||
|
|
|
|||
|
|
xmlResp.LoadXml(resp.resultado);
|
|||
|
|
|
|||
|
|
|
|||
|
|
nodo_principal = xmlResp.DocumentElement.SelectSingleNode("//Resultado");
|
|||
|
|
if (nodo_principal.SelectSingleNode("Error") != null)
|
|||
|
|
{
|
|||
|
|
nodo_error = nodo_principal.SelectSingleNode("Error").InnerText;
|
|||
|
|
respuesta.DescripcionRespuesta = nodo_error;
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string co_ente = nodo_principal.SelectSingleNode("Solicitante/co_ente").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
int flag_cliente_existe = 0;
|
|||
|
|
XmlNode cliente_existe = nodo_principal.SelectSingleNode("Solicitante/cliente_existe");
|
|||
|
|
|
|||
|
|
if (cliente_existe != null)
|
|||
|
|
{
|
|||
|
|
flag_cliente_existe = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cliente.TipoCliente == "Nuevo" && cliente.Ente == "" && flag_cliente_existe == 0)
|
|||
|
|
{
|
|||
|
|
string de_encontrado = nodo_principal.SelectSingleNode("Solicitante/ExistePadronSUGEF").InnerText;
|
|||
|
|
string de_coincide = nodo_principal.SelectSingleNode("Solicitante/NombreCoincidePadronSUGEF").InnerText;
|
|||
|
|
respuesta.DescripcionRespuesta = de_encontrado + ". " + de_coincide;
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cliente.Ente = co_ente;
|
|||
|
|
ActualizarDatosCliente(cliente);
|
|||
|
|
|
|||
|
|
var nodoDirecciones = nodo_principal.SelectSingleNode("Solicitante/Direcciones");
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (nodoDirecciones != null)
|
|||
|
|
{
|
|||
|
|
for (int current = 0; current < nodoDirecciones.ChildNodes.Count; current++)
|
|||
|
|
{
|
|||
|
|
var child = nodoDirecciones.ChildNodes.Item(current);
|
|||
|
|
string co_direccion = child.SelectSingleNode("co_direccion").InnerText;
|
|||
|
|
string co_tipo_direccion = child.SelectSingleNode("co_tipo_direccion").InnerText;
|
|||
|
|
if (co_tipo_direccion == "DM")
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DireccionCliente direccion = cliente.DireccionCliente.Where(x => x.IdTipoDireccion.Trim() == "DM").FirstOrDefault();
|
|||
|
|
if (direccion != null)
|
|||
|
|
{
|
|||
|
|
direccion.Secuencial = Convert.ToInt32(co_direccion != "" ? co_direccion : "0");
|
|||
|
|
ActualizaDireccion(direccion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var nodoTelefonos = child.SelectSingleNode("Telefonos");
|
|||
|
|
if (nodoTelefonos != null)
|
|||
|
|
{
|
|||
|
|
for (int current2 = 0; current2 < nodoTelefonos.ChildNodes.Count; current2++)
|
|||
|
|
{
|
|||
|
|
var child2 = nodoTelefonos.ChildNodes.Item(current2);
|
|||
|
|
string co_tipo_telefono = child2.SelectSingleNode("co_tipo").InnerText;
|
|||
|
|
string co_secuencial = child2.SelectSingleNode("co_secuencial").InnerText;
|
|||
|
|
|
|||
|
|
if (co_tipo_telefono == "1")
|
|||
|
|
{
|
|||
|
|
TelefonoCliente telresidencial = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DM").FirstOrDefault();
|
|||
|
|
if (telresidencial != null)
|
|||
|
|
{
|
|||
|
|
telresidencial.Secuencial = Convert.ToInt32(co_secuencial != "" ? co_secuencial : "0");
|
|||
|
|
AtualizarTelefonos(telresidencial);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (co_tipo_telefono == "5")
|
|||
|
|
{
|
|||
|
|
TelefonoCliente telfax = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DMF").FirstOrDefault();
|
|||
|
|
if (telfax != null)
|
|||
|
|
{
|
|||
|
|
telfax.Secuencial = Convert.ToInt32(co_secuencial != "" ? co_secuencial : "0");
|
|||
|
|
AtualizarTelefonos(telfax);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (co_tipo_telefono == "4")
|
|||
|
|
{
|
|||
|
|
TelefonoCliente telcel = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DMM").FirstOrDefault();
|
|||
|
|
if (telcel != null)
|
|||
|
|
{
|
|||
|
|
telcel.Secuencial = Convert.ToInt32(co_secuencial != "" ? co_secuencial : "0");
|
|||
|
|
AtualizarTelefonos(telcel);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (co_tipo_direccion == "DC")
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DireccionCliente direccion = cliente.DireccionCliente.Where(x => x.IdTipoDireccion.Trim() == "DC").FirstOrDefault();
|
|||
|
|
if (direccion != null)
|
|||
|
|
{
|
|||
|
|
direccion.Secuencial = Convert.ToInt32(co_direccion != "" ? co_direccion : "0");
|
|||
|
|
ActualizaDireccion(direccion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var nodoTelefonos = child.SelectSingleNode("Telefonos");
|
|||
|
|
if (nodoTelefonos != null)
|
|||
|
|
{
|
|||
|
|
for (int current2 = 0; current2 < nodoTelefonos.ChildNodes.Count; current2++)
|
|||
|
|
{
|
|||
|
|
var child2 = nodoTelefonos.ChildNodes.Item(current2);
|
|||
|
|
string co_tipo_telefono = child2.SelectSingleNode("co_tipo").InnerText;
|
|||
|
|
string co_secuencial = child2.SelectSingleNode("co_secuencial").InnerText;
|
|||
|
|
if (co_tipo_telefono == "2")
|
|||
|
|
{
|
|||
|
|
TelefonoCliente tellaboral = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DC").FirstOrDefault();
|
|||
|
|
if (tellaboral != null)
|
|||
|
|
{
|
|||
|
|
tellaboral.Secuencial = Convert.ToInt32(co_secuencial != "" ? co_secuencial : "0");
|
|||
|
|
AtualizarTelefonos(tellaboral);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else if (co_tipo_telefono == "7")
|
|||
|
|
{
|
|||
|
|
TelefonoCliente telfaxlaboral = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DCF").FirstOrDefault();
|
|||
|
|
if (telfaxlaboral != null)
|
|||
|
|
{
|
|||
|
|
telfaxlaboral.Secuencial = Convert.ToInt32(co_secuencial != "" ? co_secuencial : "0");
|
|||
|
|
AtualizarTelefonos(telfaxlaboral);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var nodoFuenteIngreso = nodo_principal.SelectSingleNode("Solicitante/FuentesIngreso");
|
|||
|
|
if (nodoFuenteIngreso != null)
|
|||
|
|
{
|
|||
|
|
for (int current = 0; current < nodoFuenteIngreso.ChildNodes.Count; current++)
|
|||
|
|
{
|
|||
|
|
var child = nodoFuenteIngreso.ChildNodes.Item(current);
|
|||
|
|
|
|||
|
|
string co_empleo = child.SelectSingleNode("co_empleo").InnerText;
|
|||
|
|
InformacionLaboralCliente infolaboral = cliente.InformacionLaboralCliente.OrderBy(x => x.IdInfoLaboral).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (infolaboral != null)
|
|||
|
|
{
|
|||
|
|
infolaboral.Secuencial = Convert.ToInt32(co_empleo != "" ? co_empleo : "0");
|
|||
|
|
ActualizaInfolaboral(infolaboral);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var nodoEmails = nodo_principal.SelectSingleNode("Solicitante/Emails");
|
|||
|
|
if (nodoEmails != null)
|
|||
|
|
{
|
|||
|
|
for (int current = 0; current < nodoEmails.ChildNodes.Count; current++)
|
|||
|
|
{
|
|||
|
|
var child = nodoEmails.ChildNodes.Item(current);
|
|||
|
|
string co_email = child.SelectSingleNode("co_email").InnerText;
|
|||
|
|
string co_tipo_email = child.SelectSingleNode("co_tipo_email").InnerText;
|
|||
|
|
if (co_tipo_email == "PERSONAL")
|
|||
|
|
{
|
|||
|
|
EmailCliente emailpersonal = cliente.EmailCliente.Where(x => x.IdTipoEmail == 1).FirstOrDefault();
|
|||
|
|
if (emailpersonal != null)
|
|||
|
|
{
|
|||
|
|
emailpersonal.Secuencial = Convert.ToInt32(co_email != "" ? co_email : "0");
|
|||
|
|
ActualizarEmail(emailpersonal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (co_tipo_email == "TRABAJO")
|
|||
|
|
{
|
|||
|
|
EmailCliente emailtrabajo = cliente.EmailCliente.Where(x => x.IdTipoEmail == 2).FirstOrDefault();
|
|||
|
|
if (emailtrabajo != null)
|
|||
|
|
{
|
|||
|
|
emailtrabajo.Secuencial = Convert.ToInt32(co_email != "" ? co_email : "0");
|
|||
|
|
ActualizarEmail(emailtrabajo);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "No fue posible obtener la respuesta del servicio de creación de cliente en MIS");
|
|||
|
|
respuesta.DescripcionRespuesta = "No fue posible obtener la respuesta del servicio de creación de cliente en MIS";
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
xmlDoc = null;
|
|||
|
|
nodo_principal = null;
|
|||
|
|
nodo_error = null;
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ArmarXMLSoliciante
|
|||
|
|
private string armarXMLSoliciante(int id, int tipocliente, int tipocambio, int incidente, JsonCrearOperacion consulta)
|
|||
|
|
{
|
|||
|
|
StringBuilder SBXml = new StringBuilder();
|
|||
|
|
//Cliente cliente = consulta.Solicitud.Solicitante.FirstOrDefault().Cliente;
|
|||
|
|
Cotizacion cotizacion = consulta.Solicitud.Cotizacion;
|
|||
|
|
|
|||
|
|
Cliente cliente = new Cliente();
|
|||
|
|
foreach (var x in consulta.Solicitud.Solicitante)
|
|||
|
|
{
|
|||
|
|
if (x.IdTipoSolicitante == tipocliente)
|
|||
|
|
{
|
|||
|
|
cliente = x.Cliente;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
JsonIdentificacion identificacion = TipoIdentificacion(cliente);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<?xml version='1.0'?>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<COBIS>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<Proceso>{0}</Proceso>{1}", "PrestamoPrendario", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<nu_solicitud>{0}</nu_solicitud>{1}", id.ToString(), Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<nu_incidente>{0}</nu_incidente>{1}", incidente.ToString(), Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<po_tasacambio>{0}</po_tasacambio>{1}", tipocambio.ToString(), Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region DatosSolicitante
|
|||
|
|
SBXml.AppendFormat("<DatosSolicitante>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region DatosGenerales
|
|||
|
|
SBXml.AppendFormat("<DatosGenerales>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cliente.Ente))
|
|||
|
|
SBXml.AppendFormat("<co_ente>{0}</co_ente>{1}", "0", Environment.NewLine);
|
|||
|
|
else
|
|||
|
|
SBXml.AppendFormat("<co_ente>{0}</co_ente>{1}", cliente.Ente, Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<de_cedula>{0}</de_cedula>{1}", identificacion.de_cedula != null ? identificacion.de_cedula.Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_pasaporte>{0}</de_pasaporte>{1}", identificacion.de_pasaporte != null ? identificacion.de_pasaporte.Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_primer_nombre>{0}</de_primer_nombre>{1}", cliente.PrimerNombre != null ? cliente.PrimerNombre.Trim().ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_segundo_nombre>{0}</de_segundo_nombre>{1}", cliente.SegundoNombre != null ? cliente.SegundoNombre.Trim().ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_apellido_paterno>{0}</de_apellido_paterno>{1}", cliente.PrimerApellido != null ? cliente.PrimerApellido.Trim().ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_apellido_materno>{0}</de_apellido_materno>{1}", cliente.SegundoApellido != null ? cliente.SegundoApellido.Trim().ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_apellido_casada>{0}</de_apellido_casada>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_seguro_social>{0}</de_seguro_social>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<fe_nacimiento>{0}</fe_nacimiento>{1}", cliente.FeNacimiento != null ? cliente.FeNacimiento.Value.ToString("MM/dd/yyyy") : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_nacionalidad>{0}</co_nacionalidad>{1}", cliente.IdNacionalidad != null ? cliente.IdNacionalidad.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_estado_civil>{0}</co_estado_civil>{1}", cliente.IdEstadoCivil != null ? cliente.IdEstadoCivil.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_sexo>{0}</co_sexo>{1}", cliente.IdGenero != null ? cliente.IdGenero.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_profesion>{0}</co_profesion>{1}", cliente.IdProfesion != null ? cliente.IdProfesion.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_ident>{0}</co_tipo_ident>{1}", identificacion.co_tipo_id != null ? identificacion.co_tipo_id.Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_sector_economico>{0}</co_sector_economico>{1}", "302", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_actividad_economica>{0}</co_actividad_economica>{1}", "6", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_segmentacion>{0}</co_segmentacion>{1}", "4", Environment.NewLine);
|
|||
|
|
|
|||
|
|
if (cotizacion.EjecutivoCotizacion != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_ejecutivo_contacto>{0}</co_ejecutivo_contacto>{1}", cotizacion.EjecutivoCotizacion.LoginEjecutivo != null ? cotizacion.EjecutivoCotizacion.LoginEjecutivo.Trim().ToLower() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (consulta.Solicitud != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_sucursal_gestion>{0}</co_sucursal_gestion>{1}", consulta.Solicitud.IdSucursal != null ? consulta.Solicitud.IdSucursal.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<fe_vencimiento>{0}</fe_vencimiento>{1}", cliente.FeVenceIdentificacion != null ? cliente.FeVenceIdentificacion.Value.ToString("MM/dd/yyyy") : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_categoria_riesgo>{0}</co_categoria_riesgo>{1}", cliente.IdCategoriaRiesgo != null ? cliente.IdCategoriaRiesgo.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_generador_moneda>{0}</co_generador_moneda>{1}", GeneradorMoneda(cliente.GeneradorMonedaExtranjera != null ? cliente.GeneradorMonedaExtranjera.ToString().Trim() : string.Empty), Environment.NewLine);
|
|||
|
|
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_capacidad_pago_hist>{0}</co_capacidad_pago_hist>{1}", ComportamientoPago(cliente.IdComportamientoPagoHistorico != null ? cliente.IdComportamientoPagoHistorico.ToString().Trim() : string.Empty), Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_capacidad_pago>{0}</co_capacidad_pago>{1}", CapacidadPago(cliente.IdCapacidadPago != null ? cliente.IdCapacidadPago.ToString().Trim() : string.Empty), Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_tipo_persona>{0}</co_tipo_persona>{1}", identificacion.co_tipo_persona != null ? identificacion.co_tipo_persona.Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<cedula_sugef>{0}</cedula_sugef>{1}", identificacion.cedula_sugef != null ? identificacion.cedula_sugef.Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_pais_nac>{0}</co_pais_nac>{1}", cliente.IdPaisNacimiento != null ? cliente.IdPaisNacimiento.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</DatosGenerales>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Direcciones
|
|||
|
|
SBXml.AppendFormat("<Direcciones>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region Direccion Residencial
|
|||
|
|
SBXml.AppendFormat("<Direccion>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
DireccionCliente direccion = cliente.DireccionCliente.Where(x => x.IdTipoDireccion.Trim() == "DM").FirstOrDefault();
|
|||
|
|
if (direccion != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_direccion>{0}</co_direccion>{1}", direccion.Secuencial != null ? direccion.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_pais>{0}</co_pais>{1}", "41", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_provincia>{0}</co_provincia>{1}", direccion.IdProvincia != null ? direccion.IdProvincia.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_canton>{0}</co_canton>{1}", direccion.IdCanton != null ? direccion.IdCanton.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_distrito>{0}</co_distrito>{1}", direccion.IdDistrito != null ? direccion.IdDistrito.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_domicilio>{0}</co_tipo_domicilio>{1}", "C", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_calle>{0}</de_calle>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_vivienda>{0}</de_vivienda>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_edificio>{0}</de_edificio>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_direccion>{0}</co_tipo_direccion>{1}", "DM", Environment.NewLine);
|
|||
|
|
if (cliente.CondicionVivienda != null)
|
|||
|
|
SBXml.AppendFormat("<co_alquilada>{0}</co_alquilada>{1}", Alquila(cliente.CondicionVivienda.Descripcion != null ? cliente.CondicionVivienda.Descripcion : string.Empty), Environment.NewLine);
|
|||
|
|
else
|
|||
|
|
SBXml.AppendFormat("<co_alquilada>{0}</co_alquilada>{1}", "", Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<mo_alquiler>{0}</mo_alquiler>{1}", "0.00", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_verificado>{0}</co_verificado>{1}", "N", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_direccion_exacta>{0}</de_direccion_exacta>{1}", direccion.DirExacta != null ? direccion.DirExacta.ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Telefonos
|
|||
|
|
SBXml.AppendFormat("<Telefonos>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region Tel Residencial
|
|||
|
|
TelefonoCliente telresidencial = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DM").FirstOrDefault();
|
|||
|
|
if (telresidencial != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(telresidencial.Telefono))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<Telefono>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo>{0}</co_tipo>{1}", "1", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_telefono>{0}</de_telefono>{1}", telresidencial.Telefono != null ? telresidencial.Telefono : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_secuencial>{0}</co_secuencial>{1}", telresidencial.Secuencial != null ? telresidencial.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_area>{0}</co_area>{1}", "506", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</Telefono>{0}", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Tel Fax
|
|||
|
|
TelefonoCliente telfax = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DMF").FirstOrDefault();
|
|||
|
|
if (telfax != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(telfax.Telefono))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<Telefono>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo>{0}</co_tipo>{1}", "4", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_telefono>{0}</de_telefono>{1}", telfax.Telefono != null ? telfax.Telefono : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_secuencial>{0}</co_secuencial>{1}", telfax.Secuencial != null ? telfax.Secuencial.ToString() : string.Empty, Environment.NewLine); ;
|
|||
|
|
SBXml.AppendFormat("<co_area>{0}</co_area>{1}", "506", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</Telefono>{0}", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Tel Celular
|
|||
|
|
TelefonoCliente telcel = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DMM").FirstOrDefault();
|
|||
|
|
if (telcel != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(telcel.Telefono))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<Telefono>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo>{0}</co_tipo>{1}", "5", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_telefono>{0}</de_telefono>{1}", telcel.Telefono != null ? telcel.Telefono : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_secuencial>{0}</co_secuencial>{1}", telcel.Secuencial != null ? telcel.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_area>{0}</co_area>{1}", "506", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</Telefono>{0}", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Telefonos>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Direccion>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Direccion Trabajo
|
|||
|
|
|
|||
|
|
DireccionCliente direccionlaboral = cliente.DireccionCliente.Where(x => x.IdTipoDireccion.Trim() == "DC").FirstOrDefault();
|
|||
|
|
InformacionLaboralCliente infolaboral = cliente.InformacionLaboralCliente.OrderBy(x => x.IdInfoLaboral).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (infolaboral != null)
|
|||
|
|
{
|
|||
|
|
if (infolaboral.IdFuenteIngreso != null)
|
|||
|
|
{
|
|||
|
|
//*************************************************************************
|
|||
|
|
//BMU 11-05-16 => Se comenta la condicion que indica que solo para ciertos
|
|||
|
|
//tipos de fuente de ingreso es que se envía la informacion laboral a MIS
|
|||
|
|
//*************************************************************************
|
|||
|
|
//if (infolaboral.IdFuenteIngreso.Trim() == "AEPR" || infolaboral.IdFuenteIngreso.Trim() == "AEPU" || infolaboral.IdFuenteIngreso.Trim() == "MIXT")
|
|||
|
|
//{
|
|||
|
|
|
|||
|
|
#region Direccion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<Direccion>{0}", Environment.NewLine);
|
|||
|
|
if (direccionlaboral != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_direccion>{0}</co_direccion>{1}", direccionlaboral.Secuencial != null ? direccionlaboral.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_pais>{0}</co_pais>{1}", "41", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_provincia>{0}</co_provincia>{1}", direccionlaboral.IdProvincia != null ? direccionlaboral.IdProvincia.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_canton>{0}</co_canton>{1}", direccionlaboral.IdCanton != null ? direccionlaboral.IdCanton.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_distrito>{0}</co_distrito>{1}", direccionlaboral.IdDistrito != null ? direccionlaboral.IdDistrito.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_domicilio>{0}</co_tipo_domicilio>{1}", "C", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_calle>{0}</de_calle>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_vivienda>{0}</de_vivienda>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_edificio>{0}</de_edificio>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_direccion>{0}</co_tipo_direccion>{1}", "DC", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_alquilada>{0}</co_alquilada>{1}", "N", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<mo_alquiler>{0}</mo_alquiler>{1}", "0.00", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_verificado>{0}</co_verificado>{1}", "N", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_direccion_exacta>{0}</de_direccion_exacta>{1}", direccionlaboral.DirExacta != null ? direccionlaboral.DirExacta.ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Telefonos Laboral
|
|||
|
|
SBXml.AppendFormat("<Telefonos>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region Tel Laboral
|
|||
|
|
TelefonoCliente tellaboral = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DC").FirstOrDefault();
|
|||
|
|
if (tellaboral != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(tellaboral.Telefono))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<Telefono>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo>{0}</co_tipo>{1}", "2", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_telefono>{0}</de_telefono>{1}", tellaboral.Telefono != null ? tellaboral.Telefono : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_secuencial>{0}</co_secuencial>{1}", tellaboral.Secuencial != null ? tellaboral.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_area>{0}</co_area>{1}", "506", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</Telefono>{0}", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Tel Fax Laboral
|
|||
|
|
TelefonoCliente telfaxlaboral = cliente.TelefonoCliente.Where(x => x.IdTipoTelefono.Trim() == "DCF").FirstOrDefault();
|
|||
|
|
if (telfaxlaboral != null)
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(telfaxlaboral.Telefono))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<Telefono>{0}", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo>{0}</co_tipo>{1}", "7", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_telefono>{0}</de_telefono>{1}", telfaxlaboral.Telefono != null ? telfaxlaboral.Telefono : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_secuencial>{0}</co_secuencial>{1}", telfaxlaboral.Secuencial != null ? telfaxlaboral.Secuencial.ToString() : string.Empty, Environment.NewLine); ;
|
|||
|
|
SBXml.AppendFormat("<co_area>{0}</co_area>{1}", "506", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</Telefono>{0}", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Telefonos>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Direccion>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Direcciones>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
if (infolaboral != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
#region FuentesIngreso
|
|||
|
|
SBXml.AppendFormat("<FuentesIngreso>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region FuenteIngreso
|
|||
|
|
SBXml.AppendFormat("<FuenteIngreso>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_empleo>{0}</co_empleo>{1}", infolaboral.Secuencial != null ? infolaboral.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_empresa>{0}</co_empresa>{1}", "0", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_empresa>{0}</de_empresa>{1}", infolaboral.NombreEmpresa != null ? infolaboral.NombreEmpresa.ToUpper() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_ocupacion>{0}</co_ocupacion>{1}", infolaboral.IdPuestoActual != null ? infolaboral.IdPuestoActual.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<fe_ingreso>{0}</fe_ingreso>{1}", infolaboral.FeIngreso != null ? infolaboral.FeIngreso.Value.ToString("MM/dd/yyyy") : string.Empty, Environment.NewLine);
|
|||
|
|
|
|||
|
|
|
|||
|
|
decimal ingresosnetosdolares = 0;
|
|||
|
|
decimal ingresosnetoscolones = 0;
|
|||
|
|
decimal salario = 0;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
ingresosnetosdolares = TotalIngresosNetosDolares(cliente.InformacionIngresosCliente);
|
|||
|
|
ingresosnetoscolones = TotalIngresosNetosColones(cliente.InformacionIngresosCliente);
|
|||
|
|
salario = (ingresosnetoscolones > ingresosnetosdolares * tipocambio) ? ingresosnetoscolones : ingresosnetosdolares;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex2)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Error al calcular ingresos del cliente =>" + ex2.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<mo_sueldo>{0}</mo_sueldo>{1}", salario, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_empleo>{0}</co_tipo_empleo>{1}", TipoEmpleo(infolaboral.IdFuenteIngreso != null ? infolaboral.IdFuenteIngreso : string.Empty), Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_ministerio>{0}</de_ministerio>{1}", "", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<nu_planilla>{0}</nu_planilla>{1}", "", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<nu_empleado>{0}</nu_empleado>{1}", "", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<nu_empleado_seguro>{0}</nu_empleado_seguro>{1}", "", Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_verificado>{0}</co_verificado>{1}", "N", Environment.NewLine);
|
|||
|
|
|
|||
|
|
string de_moneda = (ingresosnetoscolones > (ingresosnetosdolares * tipocambio)) ? "Colones" : "Dolares";
|
|||
|
|
string co_moneda = string.Empty;
|
|||
|
|
|
|||
|
|
switch (de_moneda)
|
|||
|
|
{
|
|||
|
|
case "Colones":
|
|||
|
|
co_moneda = "20";
|
|||
|
|
break;
|
|||
|
|
case "Dolares":
|
|||
|
|
co_moneda = "0";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("<co_moneda>{0}</co_moneda>{1}", co_moneda, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("</FuenteIngreso>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</FuentesIngreso>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Emails
|
|||
|
|
SBXml.AppendFormat("<Emails>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region Email
|
|||
|
|
SBXml.AppendFormat("<Email>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region PERSONAL
|
|||
|
|
EmailCliente emailpersonal = cliente.EmailCliente.Where(x => x.IdTipoEmail == 1).FirstOrDefault();
|
|||
|
|
if (emailpersonal != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_email>{0}</co_email>{1}", emailpersonal.Secuencial != null ? emailpersonal.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_email>{0}</de_email>{1}", emailpersonal.Email != null ? emailpersonal.Email.ToLower().Replace("ñ", "n") : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_email>{0}</co_tipo_email>{1}", "PERSONAL", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region TRABAJO
|
|||
|
|
EmailCliente emailtrabajo = cliente.EmailCliente.Where(x => x.IdTipoEmail == 2).FirstOrDefault();
|
|||
|
|
if (emailtrabajo != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_email>{0}</co_email>{1}", emailtrabajo.Secuencial != null ? emailtrabajo.Secuencial.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<de_email>{0}</de_email>{1}", emailtrabajo.Email != null ? emailtrabajo.Email.ToLower().Replace("ñ", "n") : string.Empty, Environment.NewLine);
|
|||
|
|
SBXml.AppendFormat("<co_tipo_email>{0}</co_tipo_email>{1}", "TRABAJO", Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Email>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</Emails>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
//ALR CamposRegulatorios 04-10-2017
|
|||
|
|
#region CamposRegulatorios
|
|||
|
|
SBXml.AppendFormat("<CamposRegulatorios>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
#region CamposRegulatorio
|
|||
|
|
SBXml.AppendFormat("<CampoRegulatorio>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
if (infolaboral != null)
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_declara_renta>{0}</co_declara_renta>{1}", infolaboral.IdDeclaraRenta != null ? infolaboral.IdDeclaraRenta.ToString() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_declara_renta>{0}</co_declara_renta>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
RiesgoCambiarioDeudor CodRiesgoCambiario = db.RiesgoCambiarioDeudor.Where(x => x.DescripcionRiesgoCambiarioDeudor == cliente.RiesgoCambiarioDeudor).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cliente.RiesgoCambiarioDeudor))
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_riesgo_cambiario>{0}</co_riesgo_cambiario>{1}", string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SBXml.AppendFormat("<co_riesgo_cambiario>{0}</co_riesgo_cambiario>{1}", CodRiesgoCambiario.IdRiesgoCambiarioDeudor.ToString() != null ? CodRiesgoCambiario.IdRiesgoCambiarioDeudor.ToString().Trim() : string.Empty, Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</CampoRegulatorio>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</CamposRegulatorios>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</DatosSolicitante>{0}", Environment.NewLine);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
SBXml.AppendFormat("</COBIS>{0}", Environment.NewLine);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "armarXMLSoliciante =>" + SBXml.ToString());
|
|||
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return SBXml.ToString();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ActualizarDatosCliente
|
|||
|
|
private void ActualizarDatosCliente(Cliente Model)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
Cliente data = db.Cliente.Where(x => x.IdCliente == Model.IdCliente).FirstOrDefault();
|
|||
|
|
db.Entry(data).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(Model);
|
|||
|
|
db.Entry(Model).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ActualizaDireccion
|
|||
|
|
private void ActualizaDireccion(DireccionCliente Model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
DireccionCliente data = db.DireccionCliente.Where(x => x.IdCliente == Model.IdCliente && x.IdTipoDireccion == Model.IdTipoDireccion).FirstOrDefault();
|
|||
|
|
db.Entry(data).State = EntityState.Detached;
|
|||
|
|
db.DireccionCliente.Attach(Model);
|
|||
|
|
db.Entry(Model).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region AtualizarTelefonos
|
|||
|
|
private void AtualizarTelefonos(TelefonoCliente Model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
TelefonoCliente data = db.TelefonoCliente.Where(x => x.IdCliente == Model.IdCliente && x.IdTipoTelefono == Model.IdTipoTelefono).FirstOrDefault();
|
|||
|
|
db.Entry(data).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(Model);
|
|||
|
|
db.Entry(Model).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ActualizaInfolaboral
|
|||
|
|
private void ActualizaInfolaboral(InformacionLaboralCliente Model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
InformacionLaboralCliente data = db.InformacionLaboralCliente.Where(x => x.IdCliente == Model.IdCliente).FirstOrDefault();
|
|||
|
|
db.Entry(data).State = EntityState.Detached;
|
|||
|
|
db.InformacionLaboralCliente.Attach(Model);
|
|||
|
|
db.Entry(Model).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ActualizarEmail
|
|||
|
|
private void ActualizarEmail(EmailCliente Model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
EmailCliente data = db.EmailCliente.Where(x => x.IdCliente == Model.IdCliente && x.IdTipoEmail == Model.IdTipoEmail).FirstOrDefault();
|
|||
|
|
db.Entry(data).State = EntityState.Detached;
|
|||
|
|
db.EmailCliente.Attach(Model);
|
|||
|
|
db.Entry(Model).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region TipoIdentificacion
|
|||
|
|
private JsonIdentificacion TipoIdentificacion(Cliente cliente)
|
|||
|
|
{
|
|||
|
|
JsonIdentificacion identificacion = new JsonIdentificacion();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "N";
|
|||
|
|
|
|||
|
|
switch (cliente.IdTipoIdentificacion.ToString())
|
|||
|
|
{
|
|||
|
|
case "1":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "N";
|
|||
|
|
break;
|
|||
|
|
case "2":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "R";
|
|||
|
|
break;
|
|||
|
|
case "3":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "T";
|
|||
|
|
break;
|
|||
|
|
case "4":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "A";
|
|||
|
|
break;
|
|||
|
|
case "5":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "L";
|
|||
|
|
break;
|
|||
|
|
case "6":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "X";
|
|||
|
|
break;
|
|||
|
|
case "7":
|
|||
|
|
identificacion.co_tipo_id = "P";
|
|||
|
|
identificacion.co_tipo_persona = "F";
|
|||
|
|
break;
|
|||
|
|
case "8":
|
|||
|
|
identificacion.co_tipo_id = "P";
|
|||
|
|
identificacion.co_tipo_persona = "E";
|
|||
|
|
break;
|
|||
|
|
case "11":
|
|||
|
|
identificacion.co_tipo_id = "C";
|
|||
|
|
identificacion.co_tipo_persona = "U";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (identificacion.co_tipo_id == "C")
|
|||
|
|
{
|
|||
|
|
identificacion.de_cedula = cliente.Identificacion;
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(cliente.Identificacion))
|
|||
|
|
{
|
|||
|
|
string cedulasugef = cliente.Identificacion.Replace("-", "");
|
|||
|
|
cedulasugef = cedulasugef.Substring(1, cedulasugef.Length - 1);
|
|||
|
|
identificacion.cedula_sugef = cedulasugef;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
identificacion.cedula_sugef = string.Empty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (identificacion.co_tipo_id == "P")
|
|||
|
|
{
|
|||
|
|
identificacion.de_pasaporte = cliente.Identificacion;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
return identificacion;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region GeneradorMoneda
|
|||
|
|
private string GeneradorMoneda(string de_generador_moneda)
|
|||
|
|
{
|
|||
|
|
string co_generador_moneda = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (de_generador_moneda)
|
|||
|
|
{
|
|||
|
|
case "GENERADOR DE MONEDA EXTRANJERA":
|
|||
|
|
//case "Generador de Moneda Extranjera":
|
|||
|
|
co_generador_moneda = "1";
|
|||
|
|
break;
|
|||
|
|
case "NO GENERADOR DE MONEDA EXTRANJERA DE BAJO RIESGO":
|
|||
|
|
//case "No Generador de Moneda Extranjera de Bajo Riesgo":
|
|||
|
|
co_generador_moneda = "2";
|
|||
|
|
break;
|
|||
|
|
case "NO GENERADOR DE MONEDA EXTRANJERA DE ALTO RIESGO":
|
|||
|
|
//case "No Generador de Moneda Extranjera de Alto Riesgo":
|
|||
|
|
co_generador_moneda = "3";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_generador_moneda = "4";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
return co_generador_moneda;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region ComportamientoPago
|
|||
|
|
private string ComportamientoPago(string de_comportamiento_pago)
|
|||
|
|
{
|
|||
|
|
string co_comportamiento_pago = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (de_comportamiento_pago)
|
|||
|
|
{
|
|||
|
|
case "ph1":
|
|||
|
|
co_comportamiento_pago = "1";
|
|||
|
|
break;
|
|||
|
|
case "ph2":
|
|||
|
|
co_comportamiento_pago = "2";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_comportamiento_pago = "0";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return co_comportamiento_pago;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region CapacidadPago
|
|||
|
|
private string CapacidadPago(string de_capacidad_pago)
|
|||
|
|
{
|
|||
|
|
string co_capacidad_pago = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (de_capacidad_pago)
|
|||
|
|
{
|
|||
|
|
case "cp1":
|
|||
|
|
co_capacidad_pago = "1";
|
|||
|
|
break;
|
|||
|
|
case "cp2":
|
|||
|
|
co_capacidad_pago = "2";
|
|||
|
|
break;
|
|||
|
|
case "cp3":
|
|||
|
|
co_capacidad_pago = "3";
|
|||
|
|
break;
|
|||
|
|
case "cp4":
|
|||
|
|
co_capacidad_pago = "4";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_capacidad_pago = "0";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
return co_capacidad_pago;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Alquila
|
|||
|
|
private string Alquila(string de_alquilada)
|
|||
|
|
{
|
|||
|
|
string co_alquilada = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (de_alquilada)
|
|||
|
|
{
|
|||
|
|
case "ALQUILADA":
|
|||
|
|
co_alquilada = "S";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_alquilada = "N";
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
return co_alquilada;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region TotalIngresosNetosDolares
|
|||
|
|
private decimal TotalIngresosNetosDolares(InformacionIngresosCliente info)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
decimal ret = 0;
|
|||
|
|
if (info != null)
|
|||
|
|
{
|
|||
|
|
if (info.SalarioNetoDol != null)
|
|||
|
|
ret = info.SalarioNetoDol.Value;
|
|||
|
|
if (info.VariableNetoDol != null)
|
|||
|
|
ret = info.VariableNetoDol.Value;
|
|||
|
|
if (info.OffShoreNetoDol != null)
|
|||
|
|
ret = info.OffShoreNetoDol.Value;
|
|||
|
|
if (info.OtrosNetoDol != null)
|
|||
|
|
ret = info.OtrosNetoDol.Value;
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region TotalIngresosNetosColones
|
|||
|
|
private decimal TotalIngresosNetosColones(InformacionIngresosCliente info)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
decimal ret = 0;
|
|||
|
|
if (info != null)
|
|||
|
|
{
|
|||
|
|
if (info.SalarioNetoCol != null)
|
|||
|
|
ret += info.SalarioNetoCol.Value;
|
|||
|
|
if (info.VariableNetoCol != null)
|
|||
|
|
ret += info.VariableNetoCol.Value;
|
|||
|
|
if (info.OffShoreNetoCol != null)
|
|||
|
|
ret += info.OffShoreNetoCol.Value;
|
|||
|
|
if (info.OtrosNetoCol != null)
|
|||
|
|
ret += info.OtrosNetoCol.Value;
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region TipoEmpleo
|
|||
|
|
private string TipoEmpleo(string de_tipo_empleo)
|
|||
|
|
{
|
|||
|
|
string co_tipo_empleo = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
switch (de_tipo_empleo.Trim())
|
|||
|
|
{
|
|||
|
|
case "AEPR":
|
|||
|
|
co_tipo_empleo = "6";
|
|||
|
|
break;
|
|||
|
|
case "AEPU":
|
|||
|
|
co_tipo_empleo = "6";
|
|||
|
|
break;
|
|||
|
|
case "MIXT":
|
|||
|
|
co_tipo_empleo = "6";
|
|||
|
|
break;
|
|||
|
|
case "INDP":
|
|||
|
|
co_tipo_empleo = "4";
|
|||
|
|
break;
|
|||
|
|
case "INDN":
|
|||
|
|
co_tipo_empleo = "7";
|
|||
|
|
break;
|
|||
|
|
case "PENS":
|
|||
|
|
co_tipo_empleo = "2";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_tipo_empleo = "0";
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
return co_tipo_empleo;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|