1125 lines
39 KiB
C#
1125 lines
39 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.Json;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFPrendarioSeguros;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosGenerales;
|
|||
|
|
using Ultimus.Utilitarios;
|
|||
|
|
using System.Xml;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public class ReferenciaDeudaAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
Crypt crypt = new Crypt();
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<SituacionHistorica> ListarSituacionHistorica(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
List<SituacionHistorica> respuesta = new List<SituacionHistorica>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.SituacionHistorica.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<SituacionActual> ListarSituacionActual(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
List<SituacionActual> respuesta = new List<SituacionActual>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public Cliente ObtenerDataClienteReferenciaDeudas(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
Cliente respuesta = new Cliente();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
respuesta = db.Solicitante.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == idCliente).Select(c => c.Cliente).FirstOrDefault();
|
|||
|
|
respuesta.ComportamientoPagoHistorico = db.ComportamientoPagoHistorico.Where(t => t.IdComportamientoPagoHistorico == respuesta.IdComportamientoPagoHistorico).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public SituacionHistorica ObtenerSituacionHistorica(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
return db.SituacionHistorica.First(t => t.IdSituacionHistorica == id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public SituacionActual ObtenerSituacionActual(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
return db.SituacionActual.First(t => t.IdSituacionActual == id);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public bool EliminarSituacionActual(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
SituacionActual item = db.SituacionActual.FirstOrDefault(s => s.IdSituacionActual == id);
|
|||
|
|
db.Entry(item).State = EntityState.Deleted;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public bool EliminarSituacionHistorica(int id)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
SituacionHistorica item = db.SituacionHistorica.FirstOrDefault(s => s.IdSituacionHistorica == id);
|
|||
|
|
db.Entry(item).State = EntityState.Deleted;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public BaseJsonMetadata GuardarPuntajes(Cliente req)
|
|||
|
|
{
|
|||
|
|
BaseJsonMetadata resp = new BaseJsonMetadata();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (req.IdCliente == null || req.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = "Falta el id del cliente";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
Cliente _cliente = db.Cliente.Where(c => c.IdCliente == req.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (req.CICPuntajeFinal != null) _cliente.CICPuntajeFinal = req.CICPuntajeFinal;
|
|||
|
|
if (!string.IsNullOrEmpty(req.IdComportamientoPagoHistorico)) _cliente.IdComportamientoPagoHistorico = req.IdComportamientoPagoHistorico;
|
|||
|
|
|
|||
|
|
db.Entry(_cliente).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(_cliente);
|
|||
|
|
db.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
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);
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return resp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonGuardarParticipanteResponse GuardarSituacionActual(SituacionActual s)
|
|||
|
|
{
|
|||
|
|
JsonGuardarParticipanteResponse r = new JsonGuardarParticipanteResponse();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (s.IdCliente == null || s.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = "Falta el id del deudor";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (s.IdSituacionActual == 0)
|
|||
|
|
{
|
|||
|
|
s.IdSituacionActual = db.SituacionActual.Count() == 0 ? 1 : db.SituacionActual.Max(q => q.IdSituacionActual) + 1;
|
|||
|
|
db.SituacionActual.Add(s);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(s).State = EntityState.Detached;
|
|||
|
|
db.SituacionActual.Attach(s);
|
|||
|
|
db.Entry(s).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
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);
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonGuardarParticipanteResponse GuardarSituacionHistorica(SituacionHistorica s)
|
|||
|
|
{
|
|||
|
|
JsonGuardarParticipanteResponse r = new JsonGuardarParticipanteResponse();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (s.IdCliente == null || s.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = "Falta el id del deudor";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (s.IdSituacionHistorica == 0)
|
|||
|
|
{
|
|||
|
|
s.IdSituacionHistorica = db.SituacionActual.Count() == 0 ? 1 : db.SituacionActual.Max(q => q.IdSituacionActual) + 1;
|
|||
|
|
db.SituacionHistorica.Add(s);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(s).State = EntityState.Detached;
|
|||
|
|
db.SituacionHistorica.Attach(s);
|
|||
|
|
db.Entry(s).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
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);
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerMoneda(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "N - COLONES O UNIDADES DE DESARROLLO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "E - DIVISA EXTRANJERA"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerTipoOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1 - 98 DIRECTA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2 - CRÉDITO CON OBLIGACIÓN DE DESEMBOLSO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3 - TARJETAS DE CRÉDITO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "4 - LÍNEAS DE UTILIZACIÓN AUTOMÁTICA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "5 - LÍNEA DE CRÉDITO CON COMPROMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "6",
|
|||
|
|
descripcion = "6 - LÍNEA DE CRÉDITO SIN COMPROMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "7",
|
|||
|
|
descripcion = "7 - 99 CONTINGENCIA CREDITICIA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerCondicion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "DEUDOR",
|
|||
|
|
descripcion = "DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "CO-DEUDOR",
|
|||
|
|
descripcion = "CO-DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "FIADOR/AVALISTA",
|
|||
|
|
descripcion = "FIADOR/AVALISTA"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerEstadoOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VIGENTE",
|
|||
|
|
descripcion = "1 - VIGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA <= A 90 DÍAS",
|
|||
|
|
descripcion = "2 - VENCIDA <= A 90 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA A > 90 DÍAS Y <= 180 DÍAS",
|
|||
|
|
descripcion = "3 - VENCIDA A > 90 DÍAS Y <= 180 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "VENCIDA > A 180 DÍAS",
|
|||
|
|
descripcion = "4 - 94 VENCIDA > A 180 DÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "COBRO JUDICIAL",
|
|||
|
|
descripcion = "5 - 93 COBRO JUDICIAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "NORMAL",
|
|||
|
|
descripcion = "91 NORMAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ARREGLO DE PAGO",
|
|||
|
|
descripcion = "92 - ARREGLO DE PAGO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ADMINIStrACIÓN INTERVENCIÓN JUDICIAL",
|
|||
|
|
descripcion = "95 - ADMINIStrACIÓN INTERVENCIÓN JUDICIAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "ADMINIStrACIÓN INTERVENCIÓN SUGEF",
|
|||
|
|
descripcion = "96 - ADMINIStrACIÓN INTERVENCIÓN SUGEF"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "OPERACIONES CASTIGADAS",
|
|||
|
|
descripcion = "97 - OPERACIONES CASTIGADAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "OPERACIONES BACK TO BACK",
|
|||
|
|
descripcion = "99 - OPERACIONES BACK TO BACK"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerMotivoLiquidacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "0 - CANCELACIÓN MEDIANTE PAGO DEL DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "1 - CANCELACIÓN MEDIANTE PAGO DE FIADOR/AVALISTA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "2 - VENTA DE OPERACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "3 - REFINANCIAMIENTO TOTAL DE LA MISMA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "4 - NOVACIÓN DEL DEUDOR"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "6",
|
|||
|
|
descripcion = "5 - CONDONACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "7",
|
|||
|
|
descripcion = "6 - DESCUENTO O CESIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "8",
|
|||
|
|
descripcion = "7 - ADJUDICACIÓN DE GARANTÍAS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "9",
|
|||
|
|
descripcion = "8 - DACIÓN DE GARANTÍAS EN PAGOS"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "10",
|
|||
|
|
descripcion = "9 - COMPENSACIÓN (BACK TO BACK)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "11",
|
|||
|
|
descripcion = "10 - PASADO POR INCOBRABLE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "12",
|
|||
|
|
descripcion = "11 - MANDATO LEGAL"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "13",
|
|||
|
|
descripcion = "12 - PROGRAMAS DE PREMIOS DE LA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "14",
|
|||
|
|
descripcion = "13 - APLICACIÓN DE PÓLIZAS DE SEGURO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "15",
|
|||
|
|
descripcion = "14 - CAMBIO DE NÚMERO DE OPERACIÓN"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "16",
|
|||
|
|
descripcion = "15 - VENCIMIENTO DE LA OPERACIÓN CONTINGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "17",
|
|||
|
|
descripcion = "16 - EJECUCIÓN DE LA OPERACIÓN CONTINGENTE"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "18",
|
|||
|
|
descripcion = "17 - TRASLADO A UN FIDEICOMISO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "19",
|
|||
|
|
descripcion = "18 - REFINANCIAMIENTO POR OTRA ENTIDAD"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "20",
|
|||
|
|
descripcion = "19 - ENTIDAD DESINSCRITA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "21",
|
|||
|
|
descripcion = "20 - CANCELACIÓN MEDIANTE PAGO DE UN JUZGADO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "22",
|
|||
|
|
descripcion = "21 - MÚLTIMPLES MOTIVOS QUE IMPLIQUE CPH3 (>25,000)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "23",
|
|||
|
|
descripcion = "22 - MÚLTIMPLES MOTIVOS QUE IMPLIQUE CPH3 (<25,000)"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "24",
|
|||
|
|
descripcion = "23 - CUALESQUIERA DOS O MAS MOTIVOS QUE NO IMPLIQUEN CPH3"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "25",
|
|||
|
|
descripcion = "98 - OPERACIÓN REACTIVADA"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "26",
|
|||
|
|
descripcion = "99 - DESCONOCIDO"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerPuntajeOperacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1.5",
|
|||
|
|
descripcion = "1.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2.5",
|
|||
|
|
descripcion = "2.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3.5",
|
|||
|
|
descripcion = "3.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4",
|
|||
|
|
descripcion = "4"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "4.5",
|
|||
|
|
descripcion = "4.5"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "5",
|
|||
|
|
descripcion = "5"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerComportamientoPagoHistorico(string filtro = null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
List<ComportamientoPagoHistorico> list = new List<ComportamientoPagoHistorico>();
|
|||
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|||
|
|
list = db.ComportamientoPagoHistorico.ToList();
|
|||
|
|
else
|
|||
|
|
list = db.ComportamientoPagoHistorico.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true).ToList();
|
|||
|
|
foreach (var ele in list)
|
|||
|
|
{
|
|||
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|||
|
|
catalogo.codigo = Convert.ToString(ele.IdComportamientoPagoHistorico).Trim();
|
|||
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|||
|
|
ret.Add(catalogo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return ret;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerSituacion(string filtro = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
registros = new List<JsonCatalogos>();
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "1",
|
|||
|
|
descripcion = "1 – Operación no reportada en ultimo envío"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "2",
|
|||
|
|
descripcion = "2 – Operación reportada en ultimo envío entidad inactiva"
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
registros.Add(new JsonCatalogos()
|
|||
|
|
{
|
|||
|
|
codigo = "3",
|
|||
|
|
descripcion = "3 – Operación reportada en ultimo envío entidad activa"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse ObtenerDeudasCliente(int idSolicitud, int idCliente, int idMoneda, decimal tipoCambio, bool unificado)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
List<JsonObtenerDeudasClienteResponse> listaDeudas = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
listaDeudas = new List<JsonObtenerDeudasClienteResponse>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse()
|
|||
|
|
{
|
|||
|
|
IdCliente = idCliente,
|
|||
|
|
IdSolicitud = idSolicitud,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<Solicitante> _participantes = db.Solicitante.Where(p => p.IdSolicitud == idSolicitud).ToList();
|
|||
|
|
foreach (Solicitante item in _participantes)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (item.IdTipoSolicitante == 1 || item.IdTipoSolicitante == 2)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var _deuda = new JsonObtenerDeudasClienteResponse()
|
|||
|
|
{
|
|||
|
|
TotalDeudasColones = 0,
|
|||
|
|
TotalDeudasDolares = 0,
|
|||
|
|
TotalDeudas = 0,
|
|||
|
|
IdCliente = item.IdCliente,
|
|||
|
|
IdSolicitud = idSolicitud,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Colones
|
|||
|
|
var listaDeudasColones = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == item.IdCliente && t.Moneda.Equals("N - COLONES O UNIDADES DE DESARROLLO") == true).ToList();
|
|||
|
|
foreach (var deuda in listaDeudasColones)
|
|||
|
|
{
|
|||
|
|
_deuda.TotalDeudasColones += StringtoDouble(deuda.CuotasEquivalente);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Dolares
|
|||
|
|
var listaDeudasDolares = db.SituacionActual.Where(t => t.IdSolicitud == idSolicitud && t.IdCliente == item.IdCliente && t.Moneda.Equals("E - DIVISA EXTRANJERA") == true).ToList();
|
|||
|
|
foreach (var deuda in listaDeudasDolares)
|
|||
|
|
{
|
|||
|
|
_deuda.TotalDeudasDolares += StringtoDouble(deuda.CuotasEquivalente);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
switch (idMoneda)
|
|||
|
|
{
|
|||
|
|
case 0: //COLONES
|
|||
|
|
_deuda.TotalDeudas = _deuda.TotalDeudasColones + (_deuda.TotalDeudasDolares * (double)tipoCambio);
|
|||
|
|
break;
|
|||
|
|
case 1: //DOLARES
|
|||
|
|
_deuda.TotalDeudas = _deuda.TotalDeudasDolares + (_deuda.TotalDeudasColones / (double)tipoCambio);
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
throw new Exception("El código para la moneda no se encuentra configurado para realizar el cálculo de las deudas del deudor.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (item.IdCliente == idCliente)
|
|||
|
|
{
|
|||
|
|
respuesta = _deuda;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
listaDeudas.Add(_deuda);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (unificado)
|
|||
|
|
{
|
|||
|
|
var item = listaDeudas.Where(j => j.IdCliente != idCliente).FirstOrDefault();
|
|||
|
|
if (item != null)
|
|||
|
|
{
|
|||
|
|
respuesta.TotalDeudasColones += item.TotalDeudasColones;
|
|||
|
|
respuesta.TotalDeudasDolares += item.TotalDeudasDolares;
|
|||
|
|
respuesta.TotalDeudas += item.TotalDeudas;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private double StringtoDouble(string value)
|
|||
|
|
{
|
|||
|
|
double dblResult = 0d;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
double.TryParse(value, out dblResult);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
dblResult = 0;
|
|||
|
|
}
|
|||
|
|
return dblResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse ObtenerDeudasCIC(int IdCliente, string Identificacion, int Incidente, string Proceso, int IdSolicitud)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
ObtenerDatosCICBDResponse resp = null;
|
|||
|
|
StringBuilder sbXMLResultado = null;
|
|||
|
|
XmlNode rootXMLRefinanciar = null;
|
|||
|
|
XmlDocument xmlDoc = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
xmlDoc = new XmlDocument();
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse();
|
|||
|
|
|
|||
|
|
|
|||
|
|
Identificacion = Identificacion.Replace("-", "");
|
|||
|
|
if (Identificacion.Length == 10)
|
|||
|
|
{
|
|||
|
|
Identificacion = Identificacion.Substring(1, Identificacion.Length - 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
resp = interfaces.ObtenerDatosCICBD(new ObtenerDatosCICBDRequest()
|
|||
|
|
{
|
|||
|
|
idcliente = IdCliente,
|
|||
|
|
identificacion = Identificacion,
|
|||
|
|
incidente = Incidente.ToString(),
|
|||
|
|
opcion = "1",
|
|||
|
|
proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
solicitud = IdSolicitud.ToString()
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el resultado de la consulta al sistema del CIC.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
xmlDoc.LoadXml(resp.resultado);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Informacion de la Fecha de Actualizacion del CIC
|
|||
|
|
string fechaActualizacion = string.Empty;
|
|||
|
|
string campo1 = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro1/Valor1").InnerText;
|
|||
|
|
|
|||
|
|
if (campo1.ToUpper() == "MONEDA")
|
|||
|
|
{
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor7") != null)
|
|||
|
|
{
|
|||
|
|
fechaActualizacion = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor7").InnerText;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor11") != null)
|
|||
|
|
{
|
|||
|
|
fechaActualizacion = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta1/Registro2/Valor11").InnerText;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.FechaActualizacionCIC = fechaActualizacion;
|
|||
|
|
|
|||
|
|
//Informacion de las Deudas a Refinanciar
|
|||
|
|
if (xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta3") != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
rootXMLRefinanciar = xmlDoc.DocumentElement.SelectSingleNode("//Resultado/Respuesta3");
|
|||
|
|
sbXMLResultado = new System.Text.StringBuilder();
|
|||
|
|
|
|||
|
|
sbXMLResultado.Append("<NewDataSet>");
|
|||
|
|
for (var i = 0; i < rootXMLRefinanciar.ChildNodes.Count; i++)
|
|||
|
|
{
|
|||
|
|
sbXMLResultado.Append("<Table>");
|
|||
|
|
sbXMLResultado.Append("<" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").Name + ">");
|
|||
|
|
sbXMLResultado.Append(rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").InnerText);
|
|||
|
|
sbXMLResultado.Append("</" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Entidad").Name + ">");
|
|||
|
|
|
|||
|
|
sbXMLResultado.Append("<" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").Name + ">");
|
|||
|
|
sbXMLResultado.Append(rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").InnerText);
|
|||
|
|
sbXMLResultado.Append("</" + rootXMLRefinanciar.ChildNodes[i].SelectSingleNode("Id.Operacion").Name + ">");
|
|||
|
|
sbXMLResultado.Append("</Table>");
|
|||
|
|
}
|
|||
|
|
sbXMLResultado.Append("</NewDataSet>");
|
|||
|
|
|
|||
|
|
respuesta.DeudasRefinanciarXmlCIC = sbXMLResultado.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Cliente _cliente = db.Cliente.Where(s => s.IdCliente == IdCliente).FirstOrDefault();
|
|||
|
|
if (_cliente != null)
|
|||
|
|
{
|
|||
|
|
//Datos actualizados
|
|||
|
|
_cliente.CICFeActualizacion = respuesta.FechaActualizacionCIC;
|
|||
|
|
_cliente.CICDeudasRefinanciar = respuesta.DeudasRefinanciarXmlCIC;
|
|||
|
|
|
|||
|
|
//Ejecucion de la actualizacion
|
|||
|
|
db.Entry(_cliente).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(_cliente);
|
|||
|
|
db.Entry(_cliente).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonObtenerDeudasClienteResponse EvaluarDeudasCIC(int IdCliente, string Identificacion, int Incidente, string Proceso, int IdSolicitud, string Modo, string Juicios, string MalasReferencias)
|
|||
|
|
{
|
|||
|
|
JsonObtenerDeudasClienteResponse respuesta = null;
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
EvaluarCICResponse resp = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
respuesta = new JsonObtenerDeudasClienteResponse();
|
|||
|
|
|
|||
|
|
resp = interfaces.EvaluarCIC(new EvaluarCICRequest()
|
|||
|
|
{
|
|||
|
|
idCliente = IdCliente,
|
|||
|
|
identificacion = Identificacion,
|
|||
|
|
incidente = Incidente.ToString(),
|
|||
|
|
modo = Modo,
|
|||
|
|
proceso = EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
solicitud = IdSolicitud.ToString(),
|
|||
|
|
juicios = Juicios,
|
|||
|
|
malas_ref = MalasReferencias
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(resp.resultadoCIC))
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el resultado de la evaluación a las deudas cargadas del sistema CIC.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.ResultadoEvaluacionCIC = resp.resultadoCIC;
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|