3615 lines
164 KiB
C#
3615 lines
164 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Validation;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Data.Entity;
|
|
using ULA.Davivienda.PrendarioModel.Prendario;
|
|
using ULA.Davivienda.PrestamoAutos.Commons;
|
|
using ULA.Davivienda.PrestamoAutos.Json;
|
|
using Ultimus.Interfaces;
|
|
using System.Configuration;
|
|
using Ultimus.Interfaces.UltimusForm;
|
|
using Ultimus.Interfaces.UltimusIntegration;
|
|
using Ultimus.Interfaces.UltimusRules;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Davivienda.PrestamoAutos.ServiciosCobisConsultaGeneral;
|
|
using ULA.Davivienda.PrestamoAutos.ServiciosCobisCarteraPrendario;
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosGenerales;
|
|
using MSXML2;
|
|
using System.ServiceModel;
|
|
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|
{
|
|
public class GlobalAPIController : ApiController
|
|
{
|
|
LogFile log = new LogFile();
|
|
|
|
#region GetControlsSettings
|
|
[HttpGet]
|
|
public FormSettingsJSON GetControlsSettings(string keyfiltro, string keyformulario)
|
|
{
|
|
return new MenuManager().GetControlsSetting(keyformulario, keyfiltro);
|
|
}
|
|
#endregion
|
|
|
|
#region AutenticarUsuario
|
|
[HttpPost]
|
|
public AutenticacionUltimus UserAutenticate([FromBody] CredencialesUsuario request)
|
|
{
|
|
AutenticacionUltimus ret = new AutenticacionUltimus();
|
|
try
|
|
{
|
|
string repositoryUrl = new ObtieneParametros().GetValueKeyRegedit("UltimusSignatureUrl", false);
|
|
ret.Autenticado = new UltimusManager().Autenticate(request.Usuario, request.Contrasena);
|
|
ret.RutaFirma = new UltimusManager().GetSignature(request.Usuario, repositoryUrl);
|
|
}
|
|
catch (Exception Exception)
|
|
{
|
|
ret.ResultadoTransaccion.Resultado = false;
|
|
ret.ResultadoTransaccion.Error = Exception.ToString();
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region Catalogos
|
|
|
|
#region ObtenerRubroSeguroAuto
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerRubroSeguroAuto(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = null;
|
|
try
|
|
{
|
|
ret = ObtenerRubroSeguro(EnumTipoRubroSeguro.Auto, filtro);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerRubroSeguroVida
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerRubroSeguroVida(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = null;
|
|
try
|
|
{
|
|
ret = ObtenerRubroSeguro(EnumTipoRubroSeguro.Vida, filtro);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerRubroSeguroDesempleo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerRubroSeguroDesempleo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = null;
|
|
try
|
|
{
|
|
ret = ObtenerRubroSeguro(EnumTipoRubroSeguro.Desempleo, filtro);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoFuenteIngreso
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoFuenteIngreso(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<TipoFuenteIngreso> list = new List<TipoFuenteIngreso>();
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = db.TipoFuenteIngreso.ToList();
|
|
else
|
|
list = db.TipoFuenteIngreso.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.IdFuenteIngreso).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoEmpleador
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoEmpleador(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<TipoEmpleador> list = new List<TipoEmpleador>();
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = db.TipoEmpleador.ToList();
|
|
else
|
|
list = db.TipoEmpleador.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.IdTipoEmpleador).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerProvincia
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerProvincia(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<Provincia> list = new List<Provincia>();
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = db.Provincia.ToList();
|
|
else
|
|
list = db.Provincia.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.IdProvincia).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerCanton
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerCanton(string filtro = null, string id = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<Canton> list = db.Canton.ToList();
|
|
|
|
if (!string.IsNullOrWhiteSpace(id))
|
|
{
|
|
int IdProvincia = Convert.ToInt32(id);
|
|
list = list.Where(e => e.IdProvincia == IdProvincia).ToList();
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = list.ToList();
|
|
else
|
|
list = list.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.IdCanton).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerDistrito
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerDistrito(string filtro = null, string id = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<Distrito> list = db.Distrito.ToList();
|
|
|
|
if (!string.IsNullOrWhiteSpace(id))
|
|
{
|
|
int IdCanton = Convert.ToInt32(id);
|
|
list = list.Where(e => e.IdCanton == IdCanton).ToList();
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = list.ToList();
|
|
else
|
|
list = list.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.IdDistrito).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerPuestoTrabajo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerPuestoTrabajo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<PuestoActual> list = new List<PuestoActual>();
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = db.PuestoActual.ToList();
|
|
else
|
|
list = db.PuestoActual.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.IdPuestoActual).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerEmpresaPlanilla
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerEmpresaPlanilla(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
//TODO: Integración COBIS
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = "1";
|
|
catalogo.descripcion = "EMPRESA 1";
|
|
ret.Add(catalogo);
|
|
catalogo = new JsonCatalogos();
|
|
catalogo.codigo = "2";
|
|
catalogo.descripcion = "EMPRESA 2";
|
|
ret.Add(catalogo);
|
|
catalogo = new JsonCatalogos();
|
|
catalogo.codigo = "3";
|
|
catalogo.descripcion = "EMPRESA 3";
|
|
ret.Add(catalogo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerPais
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerPais(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Nacionalidad.Where(t => t.Estado == true) : db.Nacionalidad.Where(t => t.Estado == true && t.Pais.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdNacionalidad.ToString(),
|
|
descripcion = t.Pais
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerNacionalidad
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerNacionalidad(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Nacionalidad.Where(t => t.Estado == true) : db.Nacionalidad.Where(t => t.Estado == true && t.Pais.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdNacionalidad.ToString(),
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerGenero
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerGenero(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Genero.Where(t => t.Estado == true) : db.Genero.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdGenero,
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerProfesion
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerProfesion(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.Profesion.Where(t => t.Estado == true) : db.Profesion.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdProfesion.ToString(),
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerNivelEducacion
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerNivelEducacion(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.NivelEducacion.Where(t => t.Estado == true) : db.NivelEducacion.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdNivelEducacion.ToString(),
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerEstadoCivil
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerEstadoCivil(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.EstadoCivil.Where(t => t.Estado == true) : db.EstadoCivil.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdEstadoCivil.Trim(),
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerCondicionVivienda
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerCondicionVivienda(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> registros = null;
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
registros = (string.IsNullOrWhiteSpace(filtro) ? db.CondicionVivienda.Where(t => t.Estado == true) : db.CondicionVivienda.Where(t => t.Estado == true && t.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true)).Select(t => new JsonCatalogos()
|
|
{
|
|
codigo = t.IdCondicionVivienda.ToString(),
|
|
descripcion = t.Descripcion
|
|
}).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return registros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerAgenciaVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerAgenciaVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaAgenciaVehiculo = null;
|
|
try
|
|
{
|
|
listaAgenciaVehiculo = new List<JsonCatalogos>();
|
|
List<AgenciaVehiculo> AgenciaVehiculo = new List<AgenciaVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
AgenciaVehiculo = db.AgenciaVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
AgenciaVehiculo = db.AgenciaVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in AgenciaVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdAgenciaVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaAgenciaVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaAgenciaVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerAnnoVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerAnnoVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaAnnoVehiculo = null;
|
|
try
|
|
{
|
|
listaAnnoVehiculo = new List<JsonCatalogos>();
|
|
List<AnnoVehiculo> AnnoVehiculo = new List<AnnoVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
AnnoVehiculo = db.AnnoVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
AnnoVehiculo = db.AnnoVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower())
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in AnnoVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdAnnoVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaAnnoVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaAnnoVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerMarcaVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerMarcaVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaMarcaVehiculo = null;
|
|
try
|
|
{
|
|
listaMarcaVehiculo = new List<JsonCatalogos>();
|
|
List<MarcaVehiculo> MarcaVehiculo = new List<MarcaVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
MarcaVehiculo = db.MarcaVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
MarcaVehiculo = db.MarcaVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in MarcaVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdMarcaVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaMarcaVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaMarcaVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerEstiloVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerEstiloVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaEstiloVehiculo = null;
|
|
try
|
|
{
|
|
listaEstiloVehiculo = new List<JsonCatalogos>();
|
|
List<EstiloVehiculo> EstiloVehiculo = new List<EstiloVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
EstiloVehiculo = db.EstiloVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
EstiloVehiculo = db.EstiloVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in EstiloVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdEstiloVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaEstiloVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaEstiloVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerUsoVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerUsoVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaUsoVehiculo = null;
|
|
try
|
|
{
|
|
listaUsoVehiculo = new List<JsonCatalogos>();
|
|
List<UsoVehiculo> UsoVehiculo = new List<UsoVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
UsoVehiculo = db.UsoVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
UsoVehiculo = db.UsoVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in UsoVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdUsoVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaUsoVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaUsoVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoTraccion
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoTraccion(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaTipoTraccion = null;
|
|
try
|
|
{
|
|
listaTipoTraccion = new List<JsonCatalogos>();
|
|
List<TipoTraccion> TipoTraccion = new List<TipoTraccion>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
TipoTraccion = db.TipoTraccion.Where(e => e.Estado == true).ToList();
|
|
else
|
|
TipoTraccion = db.TipoTraccion.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in TipoTraccion)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdTipoTraccion.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaTipoTraccion.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaTipoTraccion;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoTransmision
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoTransmision(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaTipoTransmision = null;
|
|
try
|
|
{
|
|
listaTipoTransmision = new List<JsonCatalogos>();
|
|
List<TipoTransmision> TipoTransmision = new List<TipoTransmision>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
TipoTransmision = db.TipoTransmision.Where(e => e.Estado == true).ToList();
|
|
else
|
|
TipoTransmision = db.TipoTransmision.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in TipoTransmision)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdTipoTransmision.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaTipoTransmision.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaTipoTransmision;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoCombustible
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoCombustible(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaTipoCombustible = null;
|
|
try
|
|
{
|
|
listaTipoCombustible = new List<JsonCatalogos>();
|
|
List<TipoCombustible> TipoCombustible = new List<TipoCombustible>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
TipoCombustible = db.TipoCombustible.Where(e => e.Estado == true).ToList();
|
|
else
|
|
TipoCombustible = db.TipoCombustible.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.Estado == true).ToList();
|
|
|
|
foreach (var n in TipoCombustible)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdTipoCombustible.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaTipoCombustible.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaTipoCombustible;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerDecision
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerDecision(string filtro = null, string id = null, string id2 = null, string id3 = null, string id4 = null)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
List<Decision> list = new List<Decision>();
|
|
|
|
if (!string.IsNullOrEmpty(id4))
|
|
{
|
|
int IdCotizacion = Convert.ToInt32(id4);
|
|
Cotizacion cot = db.Cotizacion.Where(q => q.IdCotizacion == IdCotizacion).FirstOrDefault();
|
|
|
|
if (cot != null)
|
|
{
|
|
decimal monto = 0;
|
|
if (cot.MontoPrestamo != null)
|
|
monto = cot.MontoPrestamo.Value;
|
|
|
|
List<DecisionPorEtapa> tmpList = (from de in db.DecisionPorEtapa.Include("Decision")
|
|
where de.Proceso == id
|
|
&& de.Etapa == id2
|
|
select de).ToList();
|
|
foreach (var tmpEle in tmpList)
|
|
{
|
|
bool cumpleMontoMin = true;
|
|
bool cumpleMontoMax = true;
|
|
bool cumpleGrupoIn = true;
|
|
bool cumpleGrupoNotIn = true;
|
|
|
|
if (tmpEle.MontoMin != null)
|
|
{
|
|
cumpleMontoMin = monto >= tmpEle.MontoMin.Value;
|
|
}
|
|
|
|
if (tmpEle.MontoMax != null)
|
|
{
|
|
cumpleMontoMax = monto <= tmpEle.MontoMax.Value;
|
|
}
|
|
|
|
if (tmpEle.GrupoIn != null && !string.IsNullOrEmpty(tmpEle.GrupoIn))
|
|
{
|
|
cumpleGrupoIn = new UltimusManager().IsMemberOfGroup(id3, tmpEle.GrupoIn);
|
|
}
|
|
|
|
if (tmpEle.GrupoNotIn != null && !string.IsNullOrEmpty(tmpEle.GrupoNotIn))
|
|
{
|
|
cumpleGrupoNotIn = !new UltimusManager().IsMemberOfGroup(id3, tmpEle.GrupoNotIn);
|
|
}
|
|
|
|
if (cumpleMontoMin && cumpleMontoMax && cumpleGrupoIn && cumpleGrupoNotIn)
|
|
{
|
|
list.Add(tmpEle.Decision);
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = list.ToList();
|
|
else
|
|
list = list.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.IdDecision).Trim();
|
|
catalogo.descripcion = Convert.ToString(ele.Descripcion).Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoCuenta
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoCuenta(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaTipoCuenta = null;
|
|
try
|
|
{
|
|
listaTipoCuenta = new List<JsonCatalogos>();
|
|
List<TipoCuenta> tipocuenta = new List<TipoCuenta>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
tipocuenta = db.TipoCuenta.Where(e => e.Estado == true).ToList();
|
|
else
|
|
tipocuenta = db.TipoCuenta.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in tipocuenta)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdTipoCuenta.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaTipoCuenta.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaTipoCuenta;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerCuenta
|
|
[HttpGet]
|
|
public List<JsonCuentas> ObtenerCuenta(int sol_co_solicitud)
|
|
{
|
|
List<JsonCuentas> listaCuentasInternas = null;
|
|
try
|
|
{
|
|
listaCuentasInternas = new List<JsonCuentas>();
|
|
List<CuentasInternas> cuenta = new List<CuentasInternas>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (sol_co_solicitud != null)
|
|
cuenta = db.CuentasInternas.Where(e => e.IdSolicitud == sol_co_solicitud).ToList();
|
|
foreach (var n in cuenta)
|
|
{
|
|
JsonCuentas catalogo = new JsonCuentas();
|
|
catalogo.Codigo = n.IdCuenta.ToString().Trim();
|
|
catalogo.Cuenta = n.Ncuenta.ToString().Trim();
|
|
catalogo.Moneda = db.Moneda.Where(m => m.IdMoneda == n.IdMoneda).FirstOrDefault().Descripcion;
|
|
listaCuentasInternas.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaCuentasInternas;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerTipoEnvioCuenta
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerTipoEnvioCuenta(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaTipoEnvioCuenta = null;
|
|
try
|
|
{
|
|
listaTipoEnvioCuenta = new List<JsonCatalogos>();
|
|
List<TipoEnvioCuenta> tipoenviocuenta = new List<TipoEnvioCuenta>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
tipoenviocuenta = db.TipoEnvioCuenta.Where(e => e.Estado == true).ToList();
|
|
else
|
|
tipoenviocuenta = db.TipoEnvioCuenta.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in tipoenviocuenta)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdTipoEnvioCuenta.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaTipoEnvioCuenta.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaTipoEnvioCuenta;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerFormaPago
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerFormaPago(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaFormaPago = null;
|
|
try
|
|
{
|
|
listaFormaPago = new List<JsonCatalogos>();
|
|
List<FormaPago> formapago = new List<FormaPago>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
formapago = db.FormaPago.Where(e => e.Estado == true).ToList();
|
|
else
|
|
formapago = db.FormaPago.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in formapago)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdFormaPago.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaFormaPago.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaFormaPago;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerAgenteSeguros
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerAgenteSeguros(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaAgenteSeguros = null;
|
|
try
|
|
{
|
|
listaAgenteSeguros = new List<JsonCatalogos>();
|
|
List<AgenteSeguro> itemAgenteSeguro = new List<AgenteSeguro>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
itemAgenteSeguro = db.AgenteSeguro.Where(e => e.Estado == true).ToList();
|
|
else
|
|
itemAgenteSeguro = db.AgenteSeguro.Where(e => e.NombreCompleto.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in itemAgenteSeguro)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdAgenteSeguro.ToString().Trim();
|
|
catalogo.descripcion = n.NombreCompleto.ToString().Trim() + " - Licencia:" + n.NumLicencia.ToString().Trim();
|
|
listaAgenteSeguros.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaAgenteSeguros;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerCategoriaVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerCategoriaVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaCategoriaVehiculo = null;
|
|
try
|
|
{
|
|
listaCategoriaVehiculo = new List<JsonCatalogos>();
|
|
List<CategoriaVehiculo> itemCategoriaVehiculo = new List<CategoriaVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
itemCategoriaVehiculo = db.CategoriaVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
itemCategoriaVehiculo = db.CategoriaVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in itemCategoriaVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdCategoriaVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaCategoriaVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaCategoriaVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerCarroceriaVehiculo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerCarroceriaVehiculo(string filtro = null)
|
|
{
|
|
List<JsonCatalogos> listaCarroceriaVehiculo = null;
|
|
try
|
|
{
|
|
listaCarroceriaVehiculo = new List<JsonCatalogos>();
|
|
List<CarroceriaVehiculo> itemCarroceriaVehiculo = new List<CarroceriaVehiculo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
itemCarroceriaVehiculo = db.CarroceriaVehiculo.Where(e => e.Estado == true).ToList();
|
|
else
|
|
itemCarroceriaVehiculo = db.CarroceriaVehiculo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true).ToList();
|
|
|
|
foreach (var n in itemCarroceriaVehiculo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdCarroceriaVehiculo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaCarroceriaVehiculo.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaCarroceriaVehiculo;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerMotivo
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerMotivo(string filtro = null, int? id = null)
|
|
{
|
|
List<JsonCatalogos> listaMotivo = null;
|
|
try
|
|
{
|
|
listaMotivo = new List<JsonCatalogos>();
|
|
List<Motivo> itemMotivo = new List<Motivo>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
itemMotivo = db.Motivo.Where(e => e.Estado == true && e.IdTipoMotivo == id).ToList();
|
|
else
|
|
itemMotivo = db.Motivo.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true && e.IdTipoMotivo == id).ToList();
|
|
|
|
foreach (var n in itemMotivo)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdMotivo.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaMotivo.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaMotivo;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ObtenerSucursal
|
|
[HttpGet]
|
|
public List<JsonCatalogos> ObtenerSucursal(string filtro = null, int? id = null)
|
|
{
|
|
List<JsonCatalogos> listaSucursal = null;
|
|
try
|
|
{
|
|
listaSucursal = new List<JsonCatalogos>();
|
|
List<Sucursal> itemSucursal = new List<Sucursal>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
itemSucursal = db.Sucursal.Where(e => e.Estado == true).ToList();
|
|
else
|
|
itemSucursal = db.Sucursal.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true && e.Estado == true && e.IdSucursal == id).ToList();
|
|
|
|
foreach (var n in itemSucursal)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = n.IdSucursal.ToString().Trim();
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|
listaSucursal.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
return listaSucursal;
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Enviar
|
|
[HttpPost]
|
|
public JsonResponseBase Enviar([FromBody] JsonEnviarCotizacion request)
|
|
{
|
|
string proximaEtapa = string.Empty;
|
|
JsonResponseBase respuesta = new JsonResponseBase();
|
|
HistorialDecision _model = new HistorialDecision();
|
|
try
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Inicia Envio");
|
|
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
#region VALIDACIONES
|
|
if (string.IsNullOrEmpty(request.UserId))
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Verificar el UserId";
|
|
return respuesta;
|
|
}
|
|
if (string.IsNullOrEmpty(request.TaskId))
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Verificar el TaskId";
|
|
return respuesta;
|
|
}
|
|
if (string.IsNullOrEmpty(request.Process))
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Verificar el proceso";
|
|
return respuesta;
|
|
}
|
|
if (string.IsNullOrEmpty(request.Step))
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Verificar la tarea";
|
|
return respuesta;
|
|
}
|
|
Cotizacion cot = db.Cotizacion.Where(q => q.IdCotizacion == request.IdCotizacion).FirstOrDefault();
|
|
if (cot == null)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = string.Format("La cotización {0} no existe", request.IdCotizacion);
|
|
return respuesta;
|
|
}
|
|
EjecutivoCotizacion eje = db.EjecutivoCotizacion.Where(q => q.IdCotizacion == request.IdCotizacion).FirstOrDefault();
|
|
if (eje == null)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = string.Format("El ejectuvo relacionado con la cotización {0} no existe", request.IdCotizacion);
|
|
return respuesta;
|
|
}
|
|
Solicitud sol = db.Solicitud.Where(q => q.IdCotizacion == request.IdCotizacion).FirstOrDefault();
|
|
if (sol == null)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = string.Format("La solicitud relacionada con la cotización {0} no existe", request.IdCotizacion);
|
|
return respuesta;
|
|
}
|
|
Solicitante solte = db.Solicitante.Include(e => e.Cliente).Where(q => q.IdSolicitud == sol.IdSolicitud && q.IdTipoSolicitante == (int)EnumTipoSolicitante.Deudor).FirstOrDefault();
|
|
if (solte == null)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = string.Format("El deudor relacionado con la solicitud {0} no existe", sol.IdSolicitud);
|
|
return respuesta;
|
|
}
|
|
InformacionLaboralCliente laboral = db.InformacionLaboralCliente.Where(q => q.IdCliente == solte.IdCliente && q.Valido == true).FirstOrDefault();
|
|
if (laboral == null)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Actualice la información laboral del deudor";
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Termina Validaciones");
|
|
|
|
switch (request.Step)
|
|
{
|
|
case EnumEtapas.EtapaCotizacion:
|
|
|
|
List<HistorialDecision> listHistorial = db.HistorialDecision
|
|
.Where(e => e.IdDecision == EnumDecision.IrACotizacion && e.IdSolicitud == request.IdSolicitud).ToList();
|
|
|
|
if (listHistorial.Count > 0)
|
|
{
|
|
int _IdHistorialDecision = listHistorial.Max(e => e.IdHistorialDecision);
|
|
|
|
HistorialDecision _UltimoHistoricoDecision = db.HistorialDecision
|
|
.Include(e => e.Etapas)
|
|
.Where(e => e.IdHistorialDecision == _IdHistorialDecision).FirstOrDefault();
|
|
|
|
if (_UltimoHistoricoDecision != null)
|
|
{
|
|
switch (_UltimoHistoricoDecision.Etapas.DescripcionEtapa)
|
|
{
|
|
case EnumEtapas.EtapaAprobacion1:
|
|
request.IdDecision = EnumDecision.IrAAprobacion1.ToString();
|
|
break;
|
|
case EnumEtapas.EtapaAprobacion2:
|
|
request.IdDecision = EnumDecision.IrAAprobacion2.ToString();
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EnumEtapas.EtapaAprobacion2:
|
|
|
|
switch (request.IdDecision)
|
|
{
|
|
case "14":
|
|
proximaEtapa = EnumEtapas.EtapaCotizacion;
|
|
break;
|
|
}
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(proximaEtapa))
|
|
{
|
|
List<RuleVariable> rules = new List<RuleVariable>();
|
|
rules.Add(new RuleVariable() { Name = "DECISION", Value = request.IdDecision });
|
|
proximaEtapa = new RulesManager().ObtenerProximaEtapa(request.Process, request.Step, request.Incident, rules);
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Termina Busqueda de Reglas de Etapa");
|
|
|
|
if (string.IsNullOrEmpty(proximaEtapa))
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|
respuesta.DescripcionRespuesta = "Verificar las reglas";
|
|
return respuesta;
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Inicia armado de estructuras para el Integration Layer");
|
|
|
|
UltimusManager um = new UltimusManager();
|
|
string memo = "";
|
|
string summary = sol.IdSolicitud.ToString() + " - " + (string.IsNullOrEmpty(solte.Cliente.PrimerNombre) ? "" : " " + solte.Cliente.PrimerNombre.Trim()) + (string.IsNullOrEmpty(solte.Cliente.SegundoNombre) ? "" : " " + solte.Cliente.SegundoNombre.Trim()) + (string.IsNullOrEmpty(solte.Cliente.PrimerApellido) ? "" : " " + solte.Cliente.PrimerApellido.Trim()) + (string.IsNullOrEmpty(solte.Cliente.SegundoApellido) ? "" : " " + solte.Cliente.SegundoApellido.Trim());
|
|
|
|
List<NodeVariables> variables = new List<NodeVariables>();
|
|
variables.Add(new NodeVariables() { NodeName = "TaskData.Global.Etapa", NodeValue = proximaEtapa });
|
|
|
|
if (request.Incident == 0)
|
|
{
|
|
List<object> ejecutivoCargoVenta = new List<object>();
|
|
ejecutivoCargoVenta.Add(string.Format("USER:org=Business Organization, user={0}", request.UserId));
|
|
ejecutivoCargoVenta.Add(string.Format("USER:org=Business Organization, user={0}/{1}", new ObtieneParametros().GetValueKeyRegedit("UltimusDomains", false), eje.LoginEjecutivo));
|
|
variables.Add(new NodeVariables() { NodeName = "TaskData.Global.RecipienteIniciadorEjecutivoCargoVenta", NodeValues = ejecutivoCargoVenta });
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", string.Format("Process:{0} Step:{1} Incident:{2} IdSolicitud:{3} TaskData.Global.RecipienteIniciadorEjecutivoCargoVenta:{4}", request.Process, request.Step, request.Incident, request.IdSolicitud, string.Join(";", ejecutivoCargoVenta)));
|
|
}
|
|
|
|
////////
|
|
|
|
WSHttpBinding binding = new WSHttpBinding();
|
|
binding.Security.Mode = SecurityMode.None;
|
|
binding.MaxReceivedMessageSize = int.MaxValue;
|
|
binding.MaxBufferPoolSize = int.MaxValue;
|
|
|
|
binding.CloseTimeout = new TimeSpan(0, 5, 0);
|
|
binding.OpenTimeout = new TimeSpan(0, 5, 0);
|
|
binding.ReceiveTimeout = new TimeSpan(0, 5, 0);
|
|
binding.SendTimeout = new TimeSpan(0, 5, 0);
|
|
|
|
|
|
HttpTransportSecurity security = new HttpTransportSecurity();
|
|
security.ClientCredentialType = HttpClientCredentialType.None;
|
|
binding.Security.Transport = security;
|
|
|
|
string UrlIntegration = new ObtieneParametros().GetValueKeyRegedit("UltimusIntegrationLayerUrl", false);
|
|
EndpointAddress EndPoint = new EndpointAddress(UrlIntegration);
|
|
|
|
int incidente = 0;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Inicia envio al Integration Layer");
|
|
|
|
|
|
using (Ultimus.Interfaces.UltimusIntegration.UltimusIntegrationClient IntClient = new UltimusIntegrationClient(binding, EndPoint))
|
|
{
|
|
|
|
Ultimus.Interfaces.UltimusIntegration.UltimusIncident ui;
|
|
string sError = "";
|
|
|
|
if (IntClient.GetTask(request.UserId, request.TaskId, out ui, out sError))
|
|
{
|
|
if (!IntClient.CompleteTaskWithVariables(request.UserId, request.TaskId, memo, summary, variables, out incidente, out sError))
|
|
{
|
|
throw new Exception("CompleteTaskWithVariables error: " + sError);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("GetTask error: " + sError);
|
|
}
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Terminó envio al Integration Layer");
|
|
|
|
////
|
|
//int incidente = um.CompleteTask(request.UserId, request.TaskId, memo, summary, variables);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Inicia guardado de Incidente");
|
|
|
|
if (request.Incident == 0)
|
|
{
|
|
cot.EstadoCotiza = (int)EnumEstadoCotiza.Enviada;
|
|
db.Cotizacion.Attach(cot);
|
|
db.Entry(cot).State = System.Data.Entity.EntityState.Modified;
|
|
|
|
sol.Incidente = incidente;
|
|
db.Solicitud.Attach(sol);
|
|
db.Entry(sol).State = System.Data.Entity.EntityState.Modified;
|
|
db.SaveChanges();
|
|
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Inicia registro del historial");
|
|
|
|
#region HistorialDecision
|
|
try
|
|
{
|
|
int IdHistorialDecision = 1;
|
|
if (db.HistorialDecision.Count() > 0)
|
|
IdHistorialDecision = db.HistorialDecision.Max(q => q.IdHistorialDecision) + 1;
|
|
_model.IdHistorialDecision = IdHistorialDecision;
|
|
_model.IdSolicitud = request.IdSolicitud;
|
|
_model.IdEtapa = db.Etapas.Where(x => x.DescripcionEtapa.Trim() == request.Step).FirstOrDefault().IdEtapa;
|
|
|
|
if (_model.IdEtapa == 1)
|
|
_model.IdDecision = 1;
|
|
else
|
|
_model.IdDecision = int.Parse(request.IdDecision);
|
|
|
|
_model.IdMotivo = request.IdMotivo;
|
|
_model.UsuarioFirma = request.UserId;
|
|
db.HistorialDecision.Add(_model);
|
|
|
|
db.SaveChanges();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Termina Envio");
|
|
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
Exception Exp = ex2;
|
|
while (Exp != null)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", Exp);
|
|
Exp = Exp.InnerException;
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex2);
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
respuesta.Incidente = incidente;
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException ex)
|
|
{
|
|
try
|
|
{
|
|
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);
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
|
|
Exception Exp = ex;
|
|
while (Exp != null)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", Exp);
|
|
Exp = Exp.InnerException;
|
|
}
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
#region Comentarios
|
|
[HttpPost]
|
|
public List<BitacoraComentarios> ObtenerBitacoraComentarios([FromBody] BitacoraComentarios bitacoraComentarios)
|
|
{
|
|
return new MenuManager().ObtenerComentariosProceso(bitacoraComentarios);
|
|
}
|
|
|
|
[HttpPost]
|
|
public string GuardarComentarioProceso([FromBody] BitacoraComentarios bitacoraComentarios)
|
|
{
|
|
return new MenuManager().GuardarComentarioProceso(bitacoraComentarios);
|
|
}
|
|
#endregion
|
|
|
|
#region ConsultarTasaCambio
|
|
[HttpPost]
|
|
public JsonConsultarTipoCambio ConsultarTasaCambio(JsonConsultarTipoCambio req)
|
|
{
|
|
JsonConsultarTipoCambio respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisConsultaGeneral.ConsultarTasaCambioResponse resp = null;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonConsultarTipoCambio();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
|
|
resp = interfaces.ConsultarTasaCambio(new ServiciosCobisConsultaGeneral.ConsultarTasaCambioRequest()
|
|
{
|
|
Proceso = ServiciosCobisConsultaGeneral.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|
UserName = req.Usuario,
|
|
Password = ""
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(resp.TipoCambioVenta))
|
|
{
|
|
throw new Exception("No se pudo obtener la tasa de tipo de cambio. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
respuesta.TipoCambioCompra = decimal.Parse(resp.TipoCambioCompra);
|
|
respuesta.TipoCambioVenta = decimal.Parse(resp.TipoCambioVenta);
|
|
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region StringToDateTime
|
|
public static DateTime? StringToDateTime(string value, int format)
|
|
{
|
|
DateTime? dtReturn = null;
|
|
|
|
try
|
|
{
|
|
value = value.Replace('/', '-');
|
|
string[] arrValue = value.Split(new char[] { '-' });
|
|
|
|
switch (format)
|
|
{
|
|
case 1: //dd-mm-yyyy
|
|
dtReturn = new DateTime(int.Parse(arrValue[2]), int.Parse(arrValue[1]), int.Parse(arrValue[0]));
|
|
break;
|
|
case 2://mm-dd-yyyy
|
|
dtReturn = new DateTime(int.Parse(arrValue[2]), int.Parse(arrValue[0]), int.Parse(arrValue[1]));
|
|
break;
|
|
case 3://yyyy-mm-dd
|
|
dtReturn = new DateTime(int.Parse(arrValue[0]), int.Parse(arrValue[1]), int.Parse(arrValue[2]));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
dtReturn = null;
|
|
}
|
|
return dtReturn;
|
|
}
|
|
#endregion
|
|
|
|
#region StringToInteger
|
|
public static int? StringToInteger(string value)
|
|
{
|
|
int? nReturn = null;
|
|
|
|
try
|
|
{
|
|
nReturn = int.Parse(value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
nReturn = null;
|
|
}
|
|
return nReturn;
|
|
}
|
|
#endregion
|
|
|
|
#region StringToDecimal
|
|
public static decimal? StringToDecimal(string value)
|
|
{
|
|
decimal? nReturn = null;
|
|
|
|
try
|
|
{
|
|
nReturn = decimal.Parse(value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
nReturn = null;
|
|
}
|
|
return nReturn;
|
|
}
|
|
#endregion
|
|
|
|
#region IsNumeric
|
|
public static bool IsNumeric(string value)
|
|
{
|
|
double nReturn = 0;
|
|
bool bResult = false;
|
|
try
|
|
{
|
|
nReturn = double.Parse(value);
|
|
bResult = true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
return bResult;
|
|
}
|
|
#endregion
|
|
|
|
#region ActualizarDatosOperacion
|
|
private void ActualizarDatosOperacion(DataFaseII Model)
|
|
{
|
|
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
DataFaseII data = db.DataFaseII.Where(x => x.IdSolicitud == Model.IdSolicitud).FirstOrDefault();
|
|
db.Entry(data).State = EntityState.Detached;
|
|
|
|
db.DataFaseII.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 Conexion
|
|
[HttpPost]
|
|
public JsonConexion ObtenerConexion([FromBody] JsonConexion Conexion)
|
|
{
|
|
JsonConexion respuesta = new JsonConexion();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
respuesta.RolUsuario = db.RolUsuario.Where(x => x.Usuario == Conexion.RolUsuario.Usuario).FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return respuesta;
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResponseBase GuardarConexion([FromBody] JsonConexion Conexion)
|
|
{
|
|
JsonResponseBase respuesta = new JsonResponseBase();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
RolUsuario rol = db.RolUsuario.Where(x => x.Usuario == Conexion.RolUsuario.Usuario).FirstOrDefault();
|
|
|
|
if (rol == null)
|
|
{
|
|
db.RolUsuario.Add(Conexion.RolUsuario);
|
|
}
|
|
else
|
|
{
|
|
db.Entry(rol).State = EntityState.Detached;
|
|
db.RolUsuario.Attach(Conexion.RolUsuario);
|
|
db.Entry(Conexion.RolUsuario).State = System.Data.Entity.EntityState.Modified;
|
|
}
|
|
|
|
db.SaveChanges();
|
|
respuesta.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);
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
#region GuardarDatosDecision
|
|
|
|
public void GuardarDatosDecision(JsonEnviarCotizacion Model)
|
|
{
|
|
|
|
HistorialDecision _model = new HistorialDecision();
|
|
try
|
|
{
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
int IdHistorialDecision = 1;
|
|
if (db.HistorialDecision.Count() > 0)
|
|
IdHistorialDecision = db.HistorialDecision.Max(q => q.IdHistorialDecision) + 1;
|
|
_model.IdHistorialDecision = IdHistorialDecision;
|
|
_model.IdSolicitud = Model.IdSolicitud;
|
|
_model.IdEtapa = db.Etapas.Where(x => x.DescripcionEtapa.Trim() == Model.Step).FirstOrDefault().IdEtapa;
|
|
_model.IdDecision = int.Parse(Model.IdDecision);
|
|
_model.IdMotivo = Model.IdMotivo;
|
|
_model.UsuarioFirma = Model.UserId;
|
|
db.HistorialDecision.Add(_model);
|
|
|
|
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);
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|
throw ex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ActualizarOperacion
|
|
[HttpPost]
|
|
public JsonActualizarOperacionResponse ActualizarOperacion(JsonActualizarOperacionRequest req)
|
|
{
|
|
JsonActualizarOperacionResponse respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.ActualizarOperacionCompletaResponse resp = null;
|
|
|
|
|
|
string NoOperacion = "";
|
|
DateTime? FechaInicioOperacion = null;
|
|
int? PlazoMeses = 0;
|
|
decimal? MontoPrestamo = 0;
|
|
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonActualizarOperacionResponse();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
Solicitud _modelSolicitud = (db.Solicitud
|
|
.Include(e => e.Cotizacion)
|
|
.Include(e => e.DataFaseII)
|
|
.Where(e => e.IdSolicitud == req.IdSolicitud)).FirstOrDefault();
|
|
|
|
_modelSolicitud.AplicaIntegracionConCartera = _modelSolicitud.AplicaIntegracionConCartera.HasValue ? _modelSolicitud.AplicaIntegracionConCartera : false;
|
|
if (_modelSolicitud.AplicaIntegracionConCartera.Value)
|
|
{
|
|
DataFaseII _modelDataFaseII = _modelSolicitud.DataFaseII.First();
|
|
Cotizacion _modelCotizacion = _modelSolicitud.Cotizacion;
|
|
|
|
NoOperacion = _modelDataFaseII.NoOperacion.ToString();
|
|
|
|
|
|
JsonFechaProcesoCobis respFechaProceso = ObtenerFechaProcesoCobis(new JsonRegistrarTasaEscalonadaRequest()
|
|
{
|
|
UserId = req.UserId
|
|
});
|
|
|
|
if (respFechaProceso.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respFechaProceso.DescripcionRespuesta);
|
|
}
|
|
|
|
|
|
|
|
try
|
|
{
|
|
System.Globalization.CultureInfo provider = System.Globalization.CultureInfo.InvariantCulture;
|
|
FechaInicioOperacion = DateTime.ParseExact(respFechaProceso.FechaProceso, "dd/MM/yyyy", provider);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Fecha Proceso: " + respFechaProceso.FechaProceso);
|
|
throw new Exception("No fue posible recuperar la fecha de proceso de cobis para ejecutar la regeneración de fechas");
|
|
}
|
|
|
|
|
|
|
|
PlazoMeses = _modelCotizacion.PeriodoMesesCredito;
|
|
MontoPrestamo = _modelCotizacion.MontoPrestamo;
|
|
|
|
string xmlPath = string.Format("{0}\\ActualizarOperacion.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
string xmlString = File.ReadAllText(xmlPath);
|
|
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", NoOperacion));
|
|
xmlString = xmlString.Replace("<dto:fechaInicio></dto:fechaInicio>", string.Format("<dto:fechaInicio>{0}</dto:fechaInicio>", FechaInicioOperacion.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z"));
|
|
xmlString = xmlString.Replace("<dto:plazo></dto:plazo>", string.Format("<dto:plazo>{0}</dto:plazo>", PlazoMeses.Value.ToString()));
|
|
xmlString = xmlString.Replace("<dto:monto></dto:monto>", string.Format("<dto:monto>{0}</dto:monto>", MontoPrestamo.Value.ToString()));
|
|
|
|
resp = interfaces.ActualizarOperacionCompleta(new ServiciosCobisCarteraPrendario.ActualizarOperacionCompletaRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
EstadoEtapa = req.TaskStatus,
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
throw new Exception("No se pudo obtener la respuesta de cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
MSXML2.DOMDocument xmlRespuesta = new DOMDocument();
|
|
xmlRespuesta.loadXML(resp.resultado);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 1");
|
|
|
|
respuesta.NoOperacion = xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("num_operacion").text;
|
|
respuesta.FechaInicioPrestamo = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fecha_inicio").text, 1);
|
|
respuesta.FechaRegeneracion = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fecha_inicio").text, 1);
|
|
|
|
respuesta.FechaFinPrestamo = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fecha_vencim").text, 1);
|
|
respuesta.FechaPrimerPagoCapital = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fe_1_pago_cap").text, 1);
|
|
respuesta.FechaPrimerPagoInteres = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fe_1_pago_int").text, 1);
|
|
respuesta.NumCuotas = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("num_cuotas").text);
|
|
respuesta.PlazoEnDias = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("plazo_dias").text);
|
|
respuesta.NumeroOperacionesVigentes = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("nu_ope_vigentes").text);
|
|
respuesta.MontoDesembolso = StringToDecimal(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("monto_desembolso").text);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 2");
|
|
|
|
_modelDataFaseII.FechaInicio = respuesta.FechaInicioPrestamo;
|
|
_modelDataFaseII.FechaFin = respuesta.FechaFinPrestamo;
|
|
_modelDataFaseII.FechaPrimerPagoCapital = respuesta.FechaPrimerPagoCapital;
|
|
_modelDataFaseII.FechaPrimerPagoInteres = respuesta.FechaPrimerPagoInteres;
|
|
_modelDataFaseII.NumCuotas = respuesta.NumCuotas;
|
|
_modelDataFaseII.PlazoEnDias = respuesta.PlazoEnDias;
|
|
_modelDataFaseII.NumOperacionesVigentes = respuesta.NumeroOperacionesVigentes;
|
|
_modelDataFaseII.MontoDesembolso = respuesta.MontoDesembolso;
|
|
_modelDataFaseII.FechaRegeneracion = respuesta.FechaRegeneracion;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 3");
|
|
|
|
ActualizarDatosOperacion(_modelDataFaseII);
|
|
}
|
|
}
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Exitoso la actualizacion de operacion");
|
|
|
|
//Invoca el registro de la tasa escalonada para la operacion en Cartera
|
|
JsonResponseBase respTasaEscalonada = RegistrarTasascalonada(new JsonRegistrarTasaEscalonadaRequest()
|
|
{
|
|
FechaPrimerPago = respuesta.FechaPrimerPagoCapital,
|
|
NoOperacion = respuesta.NoOperacion,
|
|
IdSolicitud = (int)req.IdSolicitud,
|
|
ProcessName = req.ProcessName,
|
|
UserId = req.UserId
|
|
});
|
|
|
|
|
|
//Por favor no cambiar codigo
|
|
if (respTasaEscalonada.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respTasaEscalonada.DescripcionRespuesta);
|
|
}
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Exitoso la creación de los escalonamientos de operacion");
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region LiquidarOperacion
|
|
[HttpPost]
|
|
public JsonLiquidarOperacionResponse LiquidarOperacion(JsonLiquidarOperacionRequest req)
|
|
{
|
|
JsonLiquidarOperacionResponse respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.GenerarLiquidacionCompletaResponse resp = null;
|
|
|
|
string NoGarantia = "";
|
|
string NoPoliza = "";
|
|
string NoBien = "";
|
|
string NoOperacion = "";
|
|
DateTime? FechaLiquidacionOperacion = null;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonLiquidarOperacionResponse();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
Solicitud _modelSolicitud = (db.Solicitud.Include(e => e.DataFaseII)
|
|
.Where(e => e.IdSolicitud == req.IdSolicitud)).FirstOrDefault();
|
|
|
|
_modelSolicitud.AplicaIntegracionConCartera = _modelSolicitud.AplicaIntegracionConCartera.HasValue ? _modelSolicitud.AplicaIntegracionConCartera : false;
|
|
if (_modelSolicitud.AplicaIntegracionConCartera.Value)
|
|
{
|
|
|
|
DataFaseII _modelDataFaseII = _modelSolicitud.DataFaseII.First();
|
|
|
|
NoOperacion = _modelDataFaseII.NoOperacion.ToString();
|
|
FechaLiquidacionOperacion = _modelDataFaseII.FechaRegeneracion;
|
|
NoGarantia = _modelDataFaseII.NumeroGarantia;
|
|
NoPoliza = _modelDataFaseII.PolizaAuto;
|
|
NoBien = _modelDataFaseII.ConsecutivoBien;
|
|
|
|
string xmlPath = string.Format("{0}\\Liquidacion.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
string xmlString = File.ReadAllText(xmlPath);
|
|
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", NoOperacion));
|
|
xmlString = xmlString.Replace("<dto:fechaLiquidacion></dto:fechaLiquidacion>", string.Format("<dto:fechaLiquidacion>{0}</dto:fechaLiquidacion>", FechaLiquidacionOperacion.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z"));
|
|
xmlString = xmlString.Replace("<dto:codExterno></dto:codExterno>", string.Format("<dto:codExterno>{0}</dto:codExterno>", NoGarantia.ToUpper()));
|
|
|
|
xmlString = xmlString.Replace("<dto:poliza></dto:poliza>", string.Format("<dto:poliza>{0}</dto:poliza>", NoPoliza.ToUpper()));
|
|
xmlString = xmlString.Replace("<dto:bien></dto:bien>", string.Format("<dto:bien>{0}</dto:bien>", NoBien.ToUpper()));
|
|
|
|
|
|
|
|
resp = interfaces.GenerarLiquidacionCompleta(new ServiciosCobisCarteraPrendario.GenerarLiquidacionCompletaRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
NumOperacion = NoOperacion,
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
|
|
throw new Exception("No se pudo obtener la respuesta de la liquidacion en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
MSXML2.DOMDocument xmlRespuesta = new DOMDocument();
|
|
xmlRespuesta.loadXML(resp.resultado);
|
|
|
|
if (xmlRespuesta.documentElement.selectSingleNode("ERROR") != null)
|
|
{
|
|
throw new Exception(xmlRespuesta.documentElement.selectSingleNode("ERROR").text);
|
|
}
|
|
|
|
if (xmlRespuesta.documentElement.selectSingleNode("DatosGenerarLiquidacionCompleta/DatosRegistrarLiquidacion/DatosLiquidacion") != null)
|
|
{
|
|
string estadoLiquidacionEnCobis = xmlRespuesta.documentElement.selectSingleNode("DatosGenerarLiquidacionCompleta/DatosRegistrarLiquidacion/DatosLiquidacion").selectSingleNode("ESTADOPROCESO").text;
|
|
if (estadoLiquidacionEnCobis.ToUpper() == "N")
|
|
{
|
|
throw new Exception("Estado de la liquidación en cobis es diferente de satisfactorio.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region CrearOperacion
|
|
[HttpPost]
|
|
public JsonCrearOperacionResponse CrearOperacion(JsonCrearOperacionRequest req)
|
|
{
|
|
JsonCrearOperacionResponse respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.GenerarOperacionCompletaResponse resp = null;
|
|
|
|
string IdActividadEconomica = "";
|
|
string IdBanderaBaseCalendario = "";
|
|
string IdCiudad = "";
|
|
string EnteDeudor = "";
|
|
string EnteCodeudor1 = "";
|
|
string EnteCodeudor2 = "";
|
|
string IdTipoCartera = "";
|
|
string CodigoOficial = "";
|
|
string IdSucursal = "";
|
|
string InstruccionesExpeciales = "";
|
|
|
|
string Comision = "";
|
|
string MontoCuota = "";
|
|
string IdCuotaBallom = "";
|
|
string IdDatosSindicados = "";
|
|
string IdDestinoRecursos = "";
|
|
string DiaPago = "";
|
|
string IdDistribucionGracia = "";
|
|
string IdDividendo = "";
|
|
string EsEvitarFeriados = "";
|
|
|
|
string FechaInicioOperacion = "";
|
|
string FechaVencimientoOperacion = "";
|
|
string IdFilial = "";
|
|
string EsFondosPropios = "";
|
|
string PeriodoGraciaCapital = "";
|
|
string PeriodoGraciaInteres = "";
|
|
string IdLineaCredito = "";
|
|
string IdMoneda = "";
|
|
string MontoPrestamo = "";
|
|
|
|
string IdNaturalezaGasto = "";
|
|
string IdOrigenFondos = "";
|
|
string IdPeriodoCapital = "";
|
|
string IdPeriodoInteres = "";
|
|
string IdPeriodoReajuste = "";
|
|
string MontoPLAS = "";
|
|
string PlazoMeses = "";
|
|
string MontoPrimaSeguroDesempleo = "";
|
|
string MontoPrimaSeguroVida = "";
|
|
string IdProducto = "";
|
|
string IdPropositoOperacion = "";
|
|
|
|
string EsReajustable = "";
|
|
string IdSector = "";
|
|
string EsSindicado = "";
|
|
string PorcentajeTasaInteres = "";
|
|
string TipoAmortizacion = "";
|
|
string IdTipoPlazo = "";
|
|
string NumCuentaFormaPago = "";
|
|
string IdTipoOperacion = "";
|
|
string IdNormalORefinanciamiento = "";
|
|
string NoOperacion = "";
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonCrearOperacionResponse();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
int? idClienteDeudor = null;
|
|
int? idClienteCodeudor = null;
|
|
Cliente _modelClienteDeudor = null;
|
|
Cliente _modelClienteCodeudor = null;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 1");
|
|
|
|
Solicitud _modelSolicitud = (db.Solicitud
|
|
.Include(e => e.Cotizacion)
|
|
.Include(e => e.PropositoCredito)
|
|
.Include("Cotizacion.EjecutivoCotizacion")
|
|
.Include("Cotizacion.CondicionesTasaCotizacion")
|
|
.Include("Cotizacion.SegurosCotizacion")
|
|
.Include("Cotizacion.SegurosCotizacion.RubroSeguro")
|
|
.Include(e => e.Solicitante)
|
|
.Include(e => e.DataFaseII).Where(e => e.IdSolicitud == req.IdSolicitud)).FirstOrDefault();
|
|
|
|
|
|
Cotizacion _modelCotizacion = _modelSolicitud.Cotizacion;
|
|
idClienteDeudor = _modelSolicitud.Solicitante.Where(e => e.IdTipoSolicitante == 1).Select(e => e.IdCliente).FirstOrDefault();
|
|
_modelClienteDeudor = db.Cliente
|
|
.Include(e => e.DireccionCliente)
|
|
.Where(e => e.IdCliente == idClienteDeudor).FirstOrDefault();
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 2");
|
|
|
|
try
|
|
{
|
|
idClienteCodeudor = _modelSolicitud.Solicitante.Where(e => e.IdTipoSolicitante == 2).Select(e => e.IdCliente).FirstOrDefault();
|
|
|
|
if (idClienteCodeudor != null)
|
|
{
|
|
_modelClienteCodeudor = db.Cliente
|
|
.Include(e => e.DireccionCliente)
|
|
.Where(e => e.IdCliente == idClienteCodeudor).FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw;
|
|
}
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 3");
|
|
|
|
DataFaseII _modelDataFase2 = _modelSolicitud.DataFaseII.FirstOrDefault();
|
|
if (_modelDataFase2 != null)
|
|
NoOperacion = Convert.ToString(_modelDataFase2.NoOperacion);
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 4");
|
|
|
|
DateTime dtFechaInicio = (DateTime)_modelDataFase2.FechaInicio;
|
|
|
|
int nDiaPago = 0;
|
|
try
|
|
{
|
|
nDiaPago = int.Parse(ConfigurationManager.AppSettings["Cartera.DiaPagoPrestamo"].ToString());
|
|
}
|
|
catch (Exception)
|
|
{
|
|
nDiaPago = 8;
|
|
}
|
|
|
|
|
|
|
|
IdActividadEconomica = _modelSolicitud.PropositoCredito.IdActividadEconomica.ToString();
|
|
IdBanderaBaseCalendario = "E";
|
|
IdCiudad = _modelClienteDeudor.DireccionCliente.Where(e => e.IdTipoDireccion.Trim() == "DM").Select(e => e.IdCanton.ToString()).FirstOrDefault();
|
|
EnteDeudor = string.IsNullOrEmpty(_modelClienteDeudor.Ente) ? string.Empty : _modelClienteDeudor.Ente.ToString();
|
|
EnteCodeudor1 = "";
|
|
EnteCodeudor2 = "";
|
|
IdTipoCartera = "0";
|
|
CodigoOficial = _modelCotizacion.EjecutivoCotizacion.CodOficial.ToString();
|
|
IdSucursal = _modelSolicitud.IdSucursal.ToString();
|
|
InstruccionesExpeciales = _modelDataFase2.InstruccionesEspeciales;
|
|
|
|
Comision = _modelCotizacion.PorcComision.ToString();
|
|
MontoCuota = _modelCotizacion.CuotaPrestamo.ToString();
|
|
IdCuotaBallom = "N";
|
|
IdDatosSindicados = "N";
|
|
IdDestinoRecursos = _modelSolicitud.PropositoCredito.IdDestino.ToString(); ;
|
|
DiaPago = nDiaPago.ToString();
|
|
IdDistribucionGracia = "N";
|
|
IdDividendo = "M";
|
|
EsEvitarFeriados = "S";
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 5");
|
|
|
|
FechaInicioOperacion = _modelDataFase2.FechaInicio.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z";
|
|
FechaVencimientoOperacion = "";
|
|
IdFilial = "1";
|
|
EsFondosPropios = "S";
|
|
|
|
|
|
switch (_modelCotizacion.IdTipoGracia)
|
|
{
|
|
case EnumGracia.NoAplica:
|
|
PeriodoGraciaCapital = "0";
|
|
PeriodoGraciaInteres = "0";
|
|
break;
|
|
case EnumGracia.EnCapital:
|
|
PeriodoGraciaCapital = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
PeriodoGraciaInteres = "0";
|
|
break;
|
|
case EnumGracia.EnInteres:
|
|
PeriodoGraciaCapital = "0";
|
|
PeriodoGraciaInteres = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
break;
|
|
case EnumGracia.EnSeguroAuto:
|
|
PeriodoGraciaCapital = "0";
|
|
PeriodoGraciaInteres = "0";
|
|
break;
|
|
case EnumGracia.EnInteresEnCapital:
|
|
PeriodoGraciaCapital = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
PeriodoGraciaInteres = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
break;
|
|
case EnumGracia.EnInteresEnCapitalEnSeguroAuto:
|
|
PeriodoGraciaCapital = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
PeriodoGraciaInteres = _modelCotizacion.PeriodoMesesGracia.ToString();
|
|
break;
|
|
default:
|
|
PeriodoGraciaCapital = "0";
|
|
PeriodoGraciaInteres = "0";
|
|
break;
|
|
}
|
|
|
|
|
|
IdLineaCredito = ConfigurationManager.AppSettings["Cartera.LineaCredito"].ToString();
|
|
IdMoneda = _modelCotizacion.IdMoneda.ToString();
|
|
MontoPrestamo = _modelCotizacion.MontoPrestamo.ToString();
|
|
|
|
IdNaturalezaGasto = _modelSolicitud.PropositoCredito.IdNaturalezaGasto.ToString();
|
|
IdOrigenFondos = _modelSolicitud.PropositoCredito.IdOrigenRecursos.ToString(); ;
|
|
IdPeriodoCapital = "1";
|
|
IdPeriodoInteres = "1";
|
|
IdPeriodoReajuste = "0";
|
|
MontoPLAS = "0";
|
|
PlazoMeses = _modelCotizacion.PeriodoMesesCredito.ToString();
|
|
MontoPrimaSeguroDesempleo = _modelCotizacion.SegurosCotizacion.Where(e => e.RubroSeguro.IdTipoRubroSeguro == 2).Select(e => e.Monto.ToString()).FirstOrDefault();
|
|
MontoPrimaSeguroVida = _modelCotizacion.SegurosCotizacion.Where(e => e.RubroSeguro.IdTipoRubroSeguro == 1).Select(e => e.Monto.ToString()).FirstOrDefault();
|
|
IdProducto = ConfigurationManager.AppSettings["Cartera.ProductoCredito"].ToString();
|
|
IdPropositoOperacion = _modelSolicitud.PropositoCredito.IdActividadEconomica.ToString();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 6");
|
|
|
|
EsReajustable = "E";
|
|
IdSector = ConfigurationManager.AppSettings["Cartera.SectorCredito"].ToString();
|
|
EsSindicado = "N";
|
|
PorcentajeTasaInteres = _modelCotizacion.CondicionesTasaCotizacion.Where(x => x.Periodo == 1).Select(x => (x.Spread + x.TasaReferencia).ToString()).FirstOrDefault();
|
|
TipoAmortizacion = "FRANCESA";
|
|
IdTipoPlazo = "M";
|
|
NumCuentaFormaPago = "";
|
|
IdTipoOperacion = _modelDataFase2.TipoOperacion.ToString();
|
|
IdNormalORefinanciamiento = "C"; //R= Refinanciamiento C=Creacion Normal
|
|
NoOperacion = ""; //Numer oOperacion a Refinanciar
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 7");
|
|
|
|
|
|
string xmlPath = string.Format("{0}\\CrearOperacion.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
string xmlString = File.ReadAllText(xmlPath);
|
|
|
|
xmlString = xmlString.Replace("<dto:actividadEco></dto:actividadEco>", string.Format("<dto:actividadEco>{0}</dto:actividadEco>", IdActividadEconomica));
|
|
|
|
xmlString = xmlString.Replace("<dto:banderaBaseCalendario></dto:banderaBaseCalendario>", string.Format("<dto:banderaBaseCalendario>{0}</dto:banderaBaseCalendario>", IdBanderaBaseCalendario));
|
|
|
|
xmlString = xmlString.Replace("<dto:codCiudad></dto:codCiudad>", string.Format("<dto:codCiudad>{0}</dto:codCiudad>", IdCiudad));
|
|
|
|
xmlString = xmlString.Replace("<dto:codCliente></dto:codCliente>", string.Format("<dto:codCliente>{0}</dto:codCliente>", EnteDeudor));
|
|
|
|
xmlString = xmlString.Replace("<dto:codeudor1></dto:codeudor1>", string.Format("<dto:codeudor1>{0}</dto:codeudor1>", EnteCodeudor1));
|
|
|
|
xmlString = xmlString.Replace("<dto:codeudor2></dto:codeudor2>", string.Format("<dto:codeudor2>{0}</dto:codeudor2>", EnteCodeudor2));
|
|
|
|
xmlString = xmlString.Replace("<dto:tipoCartera></dto:tipoCartera>", string.Format("<dto:tipoCartera>{0}</dto:tipoCartera>", IdTipoCartera));
|
|
|
|
xmlString = xmlString.Replace("<dto:codOficial></dto:codOficial>", string.Format("<dto:codOficial>{0}</dto:codOficial>", CodigoOficial));
|
|
|
|
xmlString = xmlString.Replace("<dto:codOficina></dto:codOficina>", string.Format("<dto:codOficina>{0}</dto:codOficina>", IdSucursal));
|
|
|
|
xmlString = xmlString.Replace("<dto:comentario></dto:comentario>", string.Format("<dto:comentario>{0}</dto:comentario>", InstruccionesExpeciales));
|
|
|
|
xmlString = xmlString.Replace("<dto:comision></dto:comision>", string.Format("<dto:comision>{0}</dto:comision>", Comision));
|
|
|
|
xmlString = xmlString.Replace("<dto:cuota></dto:cuota>", string.Format("<dto:cuota>{0}</dto:cuota>", MontoCuota));
|
|
|
|
xmlString = xmlString.Replace("<dto:cuotaBallom></dto:cuotaBallom>", string.Format("<dto:cuotaBallom>{0}</dto:cuotaBallom>", IdCuotaBallom));
|
|
|
|
xmlString = xmlString.Replace("<dto:datosSindicados></dto:datosSindicados>", string.Format("<dto:datosSindicados>{0}</dto:datosSindicados>", IdDatosSindicados));
|
|
|
|
xmlString = xmlString.Replace("<dto:destino></dto:destino>", string.Format("<dto:destino>{0}</dto:destino>", IdDestinoRecursos));
|
|
|
|
xmlString = xmlString.Replace("<dto:diaPago></dto:diaPago>", string.Format("<dto:diaPago>{0}</dto:diaPago>", DiaPago));
|
|
|
|
xmlString = xmlString.Replace("<dto:distribucionGracia></dto:distribucionGracia>", string.Format("<dto:distribucionGracia>{0}</dto:distribucionGracia>", IdDistribucionGracia));
|
|
|
|
xmlString = xmlString.Replace("<dto:dividendo></dto:dividendo>", string.Format("<dto:dividendo>{0}</dto:dividendo>", IdDividendo));
|
|
|
|
xmlString = xmlString.Replace("<dto:evitarFeriados></dto:evitarFeriados>", string.Format("<dto:evitarFeriados>{0}</dto:evitarFeriados>", EsEvitarFeriados));
|
|
|
|
xmlString = xmlString.Replace("<dto:fechaInicio></dto:fechaInicio>", string.Format("<dto:fechaInicio>{0}</dto:fechaInicio>", FechaInicioOperacion));
|
|
|
|
xmlString = xmlString.Replace("<dto:fechaVencOp></dto:fechaVencOp>", string.Format("<dto:fechaVencOp>{0}</dto:fechaVencOp>", FechaVencimientoOperacion));
|
|
|
|
xmlString = xmlString.Replace("<dto:filial></dto:filial>", string.Format("<dto:filial>{0}</dto:filial>", IdFilial));
|
|
|
|
xmlString = xmlString.Replace("<dto:fondosPropios></dto:fondosPropios>", string.Format("<dto:fondosPropios>{0}</dto:fondosPropios>", EsFondosPropios));
|
|
|
|
xmlString = xmlString.Replace("<dto:graciaCapital></dto:graciaCapital>", string.Format("<dto:graciaCapital>{0}</dto:graciaCapital>", PeriodoGraciaCapital));
|
|
|
|
xmlString = xmlString.Replace("<dto:graciaInteres></dto:graciaInteres>", string.Format("<dto:graciaInteres>{0}</dto:graciaInteres>", PeriodoGraciaInteres));
|
|
|
|
xmlString = xmlString.Replace("<dto:lineaCredito></dto:lineaCredito>", string.Format("<dto:lineaCredito>{0}</dto:lineaCredito>", IdLineaCredito));
|
|
|
|
xmlString = xmlString.Replace("<dto:moneda></dto:moneda>", string.Format("<dto:moneda>{0}</dto:moneda>", IdMoneda));
|
|
|
|
xmlString = xmlString.Replace("<dto:monto></dto:monto>", string.Format("<dto:monto>{0}</dto:monto>", MontoPrestamo));
|
|
|
|
xmlString = xmlString.Replace("<dto:naturalezaGasto></dto:naturalezaGasto>", string.Format("<dto:naturalezaGasto>{0}</dto:naturalezaGasto>", IdNaturalezaGasto));
|
|
|
|
xmlString = xmlString.Replace("<dto:origenFondos></dto:origenFondos>", string.Format("<dto:origenFondos>{0}</dto:origenFondos>", IdOrigenFondos));
|
|
|
|
xmlString = xmlString.Replace("<dto:periodoCapital></dto:periodoCapital>", string.Format("<dto:periodoCapital>{0}</dto:periodoCapital>", IdPeriodoCapital));
|
|
|
|
xmlString = xmlString.Replace("<dto:periodoInteres></dto:periodoInteres>", string.Format("<dto:periodoInteres>{0}</dto:periodoInteres>", IdPeriodoInteres));
|
|
|
|
xmlString = xmlString.Replace("<dto:periodoReajuste></dto:periodoReajuste>", string.Format("<dto:periodoReajuste>{0}</dto:periodoReajuste>", IdPeriodoReajuste));
|
|
|
|
xmlString = xmlString.Replace("<dto:planAsistencia></dto:planAsistencia>", string.Format("<dto:planAsistencia>{0}</dto:planAsistencia>", MontoPLAS));
|
|
|
|
xmlString = xmlString.Replace("<dto:plazo></dto:plazo>", string.Format("<dto:plazo>{0}</dto:plazo>", PlazoMeses));
|
|
|
|
xmlString = xmlString.Replace("<dto:primaSeguroDesempleo></dto:primaSeguroDesempleo>", string.Format("<dto:primaSeguroDesempleo>{0}</dto:primaSeguroDesempleo>", MontoPrimaSeguroDesempleo));
|
|
|
|
xmlString = xmlString.Replace("<dto:primaSeguroVida></dto:primaSeguroVida>", string.Format("<dto:primaSeguroVida>{0}</dto:primaSeguroVida>", MontoPrimaSeguroVida));
|
|
|
|
xmlString = xmlString.Replace("<dto:producto></dto:producto>", string.Format("<dto:producto>{0}</dto:producto>", IdProducto));
|
|
|
|
xmlString = xmlString.Replace("<dto:propositoOp></dto:propositoOp>", string.Format("<dto:propositoOp>{0}</dto:propositoOp>", IdPropositoOperacion));
|
|
|
|
xmlString = xmlString.Replace("<dto:reajustable></dto:reajustable>", string.Format("<dto:reajustable>{0}</dto:reajustable>", EsReajustable));
|
|
|
|
xmlString = xmlString.Replace("<dto:sector></dto:sector>", string.Format("<dto:sector>{0}</dto:sector>", IdSector));
|
|
|
|
xmlString = xmlString.Replace("<dto:sindicado></dto:sindicado>", string.Format("<dto:sindicado>{0}</dto:sindicado>", EsSindicado));
|
|
|
|
xmlString = xmlString.Replace("<dto:tasa></dto:tasa>", string.Format("<dto:tasa>{0}</dto:tasa>", PorcentajeTasaInteres));
|
|
|
|
xmlString = xmlString.Replace("<dto:tipoAmortizacion></dto:tipoAmortizacion>", string.Format("<dto:tipoAmortizacion>{0}</dto:tipoAmortizacion>", TipoAmortizacion));
|
|
|
|
xmlString = xmlString.Replace("<dto:tipoPlazo></dto:tipoPlazo>", string.Format("<dto:tipoPlazo>{0}</dto:tipoPlazo>", IdTipoPlazo));
|
|
|
|
xmlString = xmlString.Replace("<dto:cuenta></dto:cuenta>", string.Format("<dto:cuenta>{0}</dto:cuenta>", NumCuentaFormaPago));
|
|
|
|
xmlString = xmlString.Replace("<dto:tOperacion></dto:tOperacion>", string.Format("<dto:tOperacion>{0}</dto:tOperacion>", IdTipoOperacion));
|
|
|
|
xmlString = xmlString.Replace("<dto:operacion></dto:operacion>", string.Format("<dto:operacion>{0}</dto:operacion>", IdNormalORefinanciamiento));
|
|
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", NoOperacion));
|
|
|
|
//xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", NoOperacion));
|
|
//xmlString = xmlString.Replace("<dto:fechaLiquidacion></dto:fechaLiquidacion>", string.Format("<dto:fechaLiquidacion>{0}</dto:fechaLiquidacion>", FechaLiquidacionOperacion.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z"));
|
|
//xmlString = xmlString.Replace("<dto:codExterno></dto:codExterno>", string.Format("<dto:codExterno>{0}</dto:codExterno>", NoGarantia));
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "8 -->" + xmlString);
|
|
|
|
|
|
|
|
resp = interfaces.GenerarOperacionCompleta(new ServiciosCobisCarteraPrendario.GenerarOperacionCompletaRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
NumOperacion = NoOperacion,
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
|
|
throw new Exception("No se pudo obtener la respuesta de la liquidacion en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
MSXML2.DOMDocument xmlRespuesta = new DOMDocument();
|
|
xmlRespuesta.loadXML(resp.resultado);
|
|
|
|
if (xmlRespuesta.documentElement.selectSingleNode("ERROR") != null)
|
|
{
|
|
throw new Exception(xmlRespuesta.documentElement.selectSingleNode("ERROR").text);
|
|
}
|
|
|
|
|
|
respuesta.NoOperacion = xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("num_operacion").text;
|
|
respuesta.FechaInicioPrestamo = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fecha_inicio").text, 1);
|
|
respuesta.FechaFinPrestamo = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fecha_vencim").text, 1);
|
|
respuesta.FechaPrimerPagoCapital = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fe_1_pago_cap").text, 1);
|
|
respuesta.FechaPrimerPagoInteres = StringToDateTime(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("fe_1_pago_int").text, 1);
|
|
respuesta.NumCuotas = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("num_cuotas").text);
|
|
respuesta.PlazoEnDias = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("plazo_dias").text);
|
|
respuesta.NumeroOperacionesVigentes = StringToInteger(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("nu_ope_vigentes").text);
|
|
respuesta.MontoDesembolso = StringToDecimal(xmlRespuesta.selectSingleNode("Resultado").childNodes[0].childNodes[0].childNodes[0].selectSingleNode("monto_desembolso").text);
|
|
|
|
_modelDataFase2.NoOperacion = respuesta.NoOperacion;
|
|
_modelDataFase2.FechaInicio = respuesta.FechaInicioPrestamo;
|
|
_modelDataFase2.FechaFin = respuesta.FechaFinPrestamo;
|
|
_modelDataFase2.FechaPrimerPagoCapital = respuesta.FechaPrimerPagoCapital;
|
|
_modelDataFase2.FechaPrimerPagoInteres = respuesta.FechaPrimerPagoInteres;
|
|
_modelDataFase2.NumCuotas = respuesta.NumCuotas;
|
|
_modelDataFase2.PlazoEnDias = respuesta.PlazoEnDias;
|
|
_modelDataFase2.NumOperacionesVigentes = respuesta.NumeroOperacionesVigentes;
|
|
_modelDataFase2.MontoDesembolso = respuesta.MontoDesembolso;
|
|
|
|
ActualizarDatosOperacion(_modelDataFase2);
|
|
|
|
}
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region RegistrarTasascalonada
|
|
[HttpPost]
|
|
public JsonResponseBase RegistrarTasascalonada(JsonRegistrarTasaEscalonadaRequest req)
|
|
{
|
|
JsonResponseBase respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.RegistrarTasaEscalonadaResponse resp = null;
|
|
|
|
string _NumOperacion = string.Empty;
|
|
string _Fecha = string.Empty;
|
|
string _Porcentaje = string.Empty;
|
|
string _Referencial = string.Empty;
|
|
string _Signo = string.Empty;
|
|
string _Spread = string.Empty;
|
|
string _TasaMin = string.Empty;
|
|
string _TasaMax = string.Empty;
|
|
string _Periocidad = string.Empty;
|
|
string _Observacion = string.Empty;
|
|
int? _TipoTasa = null;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonResponseBase();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
Solicitud _Solicitud = db.Solicitud
|
|
.Include(s => s.Cotizacion)
|
|
.Include("Cotizacion.CondicionesTasaCotizacion")
|
|
.Include("Cotizacion.CondicionesTasaCotizacion.TipoTasaReferencia")
|
|
.Where(s => s.IdSolicitud == req.IdSolicitud).FirstOrDefault();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 1");
|
|
|
|
|
|
Cotizacion _Cotizacion = _Solicitud.Cotizacion;
|
|
|
|
string xmlPath = string.Format("{0}\\CrearTasaEscalonada.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
string xmlString = string.Empty;
|
|
|
|
DateTime _fechaRegistro = (DateTime)req.FechaPrimerPago;
|
|
bool _IsSoloTasaFija = false;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 2");
|
|
|
|
|
|
if (_Cotizacion.CondicionesTasaCotizacion.Count == 1)
|
|
if ((int)_Cotizacion.CondicionesTasaCotizacion.First().IdTipoTasa == (int)EnumTipoTasa.FIJA)
|
|
_IsSoloTasaFija = true;
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 3");
|
|
|
|
var Ordenamiento = _Cotizacion.CondicionesTasaCotizacion.OrderBy(x => x.Periodo);
|
|
foreach (CondicionesTasaCotizacion _CondicionTasaCotizacion in Ordenamiento)
|
|
{
|
|
string[] arrOperacion = new string[] { "I" };
|
|
|
|
|
|
//*************************************************************
|
|
//No registra el primer periodo en el escalonamiento
|
|
//ya que hereda las condiciones con que fue creada la operacion
|
|
//*************************************************************
|
|
if (_CondicionTasaCotizacion.Periodo != 1)
|
|
{
|
|
|
|
foreach (string _Operacion in arrOperacion)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 4=> Operacion: " + _Operacion);
|
|
|
|
_NumOperacion = req.NoOperacion;
|
|
_Fecha = _fechaRegistro.ToString("yyyy-MM-dd") + "T06:00:00.0000Z";
|
|
_Porcentaje = (_CondicionTasaCotizacion.Spread + _CondicionTasaCotizacion.TasaReferencia).ToString();
|
|
_Referencial = _CondicionTasaCotizacion.TipoTasaReferencia.Nemonico;
|
|
_Signo = "+";
|
|
_Spread = _CondicionTasaCotizacion.Spread.ToString();
|
|
_TasaMin = _CondicionTasaCotizacion.TasaMinima.ToString();
|
|
_TasaMax = "100";
|
|
_TipoTasa = _CondicionTasaCotizacion.IdTipoTasa;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 4");
|
|
|
|
if (_CondicionTasaCotizacion.IdPeriodoReajuste.Trim() == EnumPeriodoReajuste.ANUAL.key)
|
|
_Periocidad = EnumPeriodoReajuste.ANUAL.value.ToString();
|
|
|
|
if (_CondicionTasaCotizacion.IdPeriodoReajuste.Trim() == EnumPeriodoReajuste.MENSUAL.key)
|
|
_Periocidad = EnumPeriodoReajuste.MENSUAL.value.ToString();
|
|
|
|
if (_CondicionTasaCotizacion.IdPeriodoReajuste.Trim() == EnumPeriodoReajuste.SEMESTRAL.key)
|
|
_Periocidad = EnumPeriodoReajuste.SEMESTRAL.value.ToString();
|
|
|
|
if (_CondicionTasaCotizacion.IdPeriodoReajuste.Trim() == EnumPeriodoReajuste.TRIMESTRAL.key)
|
|
_Periocidad = EnumPeriodoReajuste.TRIMESTRAL.value.ToString();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 6");
|
|
|
|
xmlString = File.ReadAllText(xmlPath);
|
|
|
|
xmlString = xmlString.Replace("<dto:operacion></dto:operacion>", string.Format("<dto:operacion>{0}</dto:operacion>", _Operacion));
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", _NumOperacion));
|
|
xmlString = xmlString.Replace("<dto:fecha></dto:fecha>", string.Format("<dto:fecha>{0}</dto:fecha>", _Fecha));
|
|
xmlString = xmlString.Replace("<dto:periocidad></dto:periocidad>", string.Format("<dto:periocidad>{0}</dto:periocidad>", _Periocidad));
|
|
xmlString = xmlString.Replace("<dto:observacion></dto:observacion>", string.Format("<dto:observacion>{0}</dto:observacion>", _Observacion));
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 7");
|
|
|
|
//**********************************************************
|
|
//Si es solo tasa fija
|
|
//**********************************************************
|
|
if (_IsSoloTasaFija)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 8");
|
|
//**********************************************************
|
|
//Envia a la interface el porcentaje de tasa fija
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:porcentaje></dto:porcentaje>", string.Format("<dto:porcentaje>{0}</dto:porcentaje>", _Porcentaje));
|
|
|
|
//**********************************************************
|
|
//Limpia de la trama los campos para tasa escalonada
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:referencial></dto:referencial>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:signo></dto:signo>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:spread></dto:spread>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:tasaMin></dto:tasaMin>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:tasaMax></dto:tasaMax>", string.Empty);
|
|
}
|
|
else
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 9");
|
|
|
|
//**********************************************************
|
|
//Si es tasa fija
|
|
//**********************************************************
|
|
if (_TipoTasa == (int)EnumTipoTasa.FIJA)
|
|
{
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 10");
|
|
//**********************************************************
|
|
//Envia a la interface el porcentaje de tasa fija
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:porcentaje></dto:porcentaje>", string.Format("<dto:porcentaje>{0}</dto:porcentaje>", _Porcentaje));
|
|
|
|
//**********************************************************
|
|
//Limpia de la trama los campos para tasa escalonada
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:referencial></dto:referencial>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:signo></dto:signo>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:spread></dto:spread>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:tasaMin></dto:tasaMin>", string.Empty);
|
|
xmlString = xmlString.Replace("<dto:tasaMax></dto:tasaMax>", string.Empty);
|
|
}
|
|
else
|
|
{
|
|
//**********************************************************
|
|
//Si es tasa variable
|
|
//**********************************************************
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 11");
|
|
|
|
//**********************************************************
|
|
//Limpia de la trama el campo para tasa fija
|
|
//Importante:Si hay periodo de fija va a incluirse dentro del escalonamiento
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:porcentaje></dto:porcentaje>", string.Empty);
|
|
|
|
//**********************************************************
|
|
//Envia a la interface los campos para tasa escalonada
|
|
//**********************************************************
|
|
xmlString = xmlString.Replace("<dto:referencial></dto:referencial>", string.Format("<dto:referencial>{0}</dto:referencial>", _Referencial));
|
|
xmlString = xmlString.Replace("<dto:signo></dto:signo>", string.Format("<dto:signo>{0}</dto:signo>", _Signo));
|
|
xmlString = xmlString.Replace("<dto:spread></dto:spread>", string.Format("<dto:spread>{0}</dto:spread>", _Spread));
|
|
xmlString = xmlString.Replace("<dto:tasaMin></dto:tasaMin>", string.Format("<dto:tasaMin>{0}</dto:tasaMin>", _TasaMin));
|
|
xmlString = xmlString.Replace("<dto:tasaMax></dto:tasaMax>", string.Format("<dto:tasaMax>{0}</dto:tasaMax>", _TasaMax));
|
|
}
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 12");
|
|
|
|
resp = interfaces.RegistrarTasaEscalonada(new ServiciosCobisCarteraPrendario.RegistrarTasaEscalonadaRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
|
|
throw new Exception("No se pudo obtener la respuesta del registro de tasa escalonada en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 13");
|
|
}
|
|
}
|
|
|
|
//**********************************************************
|
|
//Calcula la siguiente fecha a registrar de escalonamiento
|
|
//**********************************************************
|
|
_fechaRegistro = _fechaRegistro.AddMonths((int)_CondicionTasaCotizacion.PlazoMeses - (_CondicionTasaCotizacion.Periodo == 1 ? 1 : 0));
|
|
|
|
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 14");
|
|
|
|
}
|
|
}
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region RegistrarCodeudor
|
|
[HttpPost]
|
|
public JsonResponseBase RegistrarCodeudor(JsonRegistrarTasaEscalonadaRequest req)
|
|
{
|
|
JsonResponseBase respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.RegistrarCodeudorResponse resp = null;
|
|
|
|
|
|
string _NumOperacion = string.Empty;
|
|
string _EnteCodeudor = string.Empty;
|
|
string _IdentificacionCodeudor = string.Empty;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonResponseBase();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
Solicitud _Solicitud = db.Solicitud
|
|
.Include(s => s.Solicitante)
|
|
.Include(s => s.DataFaseII)
|
|
.Include("Solicitante.Cliente")
|
|
.Where(s => s.IdSolicitud == req.IdSolicitud).FirstOrDefault();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 1");
|
|
|
|
_Solicitud.AplicaIntegracionConCartera = _Solicitud.AplicaIntegracionConCartera.HasValue ? _Solicitud.AplicaIntegracionConCartera : false;
|
|
|
|
if (_Solicitud.AplicaIntegracionConCartera.Value)
|
|
{
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 2");
|
|
|
|
if (_Solicitud.DataFaseII != null & _Solicitud.DataFaseII.Count > 0)
|
|
_NumOperacion = _Solicitud.DataFaseII.First().NoOperacion;
|
|
else
|
|
throw new Exception("No se pudo obtener el numero de operación, por favor contacte al Administrador del Sistema.");
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 3");
|
|
|
|
string xmlPath = string.Format("{0}\\CrearCodeudor.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
string xmlString = string.Empty;
|
|
|
|
foreach (Solicitante _Solicitante in _Solicitud.Solicitante)
|
|
{
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 4");
|
|
|
|
if (_Solicitante.IdTipoSolicitante == 2)
|
|
{
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 5");
|
|
_EnteCodeudor = _Solicitante.Cliente.Ente;
|
|
_IdentificacionCodeudor = _Solicitante.Cliente.Identificacion;
|
|
|
|
xmlString = File.ReadAllText(xmlPath);
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", _NumOperacion));
|
|
xmlString = xmlString.Replace("<dto:codCliente></dto:codCliente>", string.Format("<dto:codCliente>{0}</dto:codCliente>", _EnteCodeudor));
|
|
xmlString = xmlString.Replace("<dto:identificacion></dto:identificacion>", string.Format("<dto:identificacion>{0}</dto:identificacion>", _IdentificacionCodeudor));
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 6=>" + xmlString);
|
|
|
|
|
|
resp = interfaces.RegistrarCodeudor(new ServiciosCobisCarteraPrendario.RegistrarCodeudorRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId
|
|
});
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 7");
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 8");
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
throw new Exception("No se pudo obtener la respuesta del registro del codeudor en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Falg 9");
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region RegistrarSeguro
|
|
[HttpPost]
|
|
public JsonResponseBase RegistrarSeguro(JsonRegistrarTasaEscalonadaRequest req)
|
|
{
|
|
JsonResponseBase respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisCarteraPrendario.RegistrarSeguroResponse resp = null;
|
|
|
|
string _Aseguradora = string.Empty;
|
|
string _NumOperacion = string.Empty;
|
|
string _TipoRubro = string.Empty;
|
|
string _Moneda = string.Empty;
|
|
string _fechaConst = string.Empty;
|
|
string _fechaFin = string.Empty;
|
|
string _frecuencia = string.Empty;
|
|
|
|
string _monto = string.Empty;
|
|
string _sucursal = string.Empty;
|
|
string _codigoExterno = string.Empty;
|
|
string _porcentajeRecarVida = "0";
|
|
string _porcentajeRecarItp = "0";
|
|
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonResponseBase();
|
|
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
Solicitud _Solicitud = db.Solicitud
|
|
.Include(s => s.Cotizacion)
|
|
.Include(s => s.DataFaseII)
|
|
.Include("Cotizacion.SegurosCotizacion")
|
|
.Include("Cotizacion.SegurosCotizacion.RubroSeguro")
|
|
.Where(s => s.IdSolicitud == req.IdSolicitud).FirstOrDefault();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 1");
|
|
|
|
|
|
Cotizacion _Cotizacion = _Solicitud.Cotizacion;
|
|
|
|
_Solicitud.AplicaIntegracionConCartera = _Solicitud.AplicaIntegracionConCartera.HasValue ? _Solicitud.AplicaIntegracionConCartera : false;
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 2");
|
|
|
|
if (_Solicitud.AplicaIntegracionConCartera.Value)
|
|
{
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 3");
|
|
|
|
if (_Solicitud.DataFaseII != null & _Solicitud.DataFaseII.Count > 0)
|
|
_NumOperacion = _Solicitud.DataFaseII.First().NoOperacion;
|
|
else
|
|
throw new Exception("No se pudo obtener el numero de operación, por favor contacte al Administrador del Sistema.");
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 4");
|
|
|
|
|
|
foreach (SegurosCotizacion _SegCotizacion in _Cotizacion.SegurosCotizacion)
|
|
{
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 5");
|
|
|
|
if (_SegCotizacion.RubroSeguro.IdTipoRubroSeguro != (int)EnumTipoRubroSeguro.Auto)
|
|
{
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 6");
|
|
|
|
string xmlString = string.Empty;
|
|
string xmlPath = string.Format("{0}\\RegistrarSeguro.xml", ConfigurationManager.AppSettings["XmlPath"]);
|
|
xmlString = File.ReadAllText(xmlPath);
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 7");
|
|
|
|
_Aseguradora = string.Format("00{0}", _SegCotizacion.RubroSeguro.IdAseguradora);
|
|
|
|
|
|
switch (_SegCotizacion.RubroSeguro.IdTipoRubroSeguro)
|
|
{
|
|
case (int)EnumTipoRubroSeguro.Desempleo:
|
|
_TipoRubro = "D";
|
|
break;
|
|
case (int)EnumTipoRubroSeguro.Vida:
|
|
_TipoRubro = "V";
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 8");
|
|
|
|
_Moneda = _Cotizacion.IdMoneda.ToString();
|
|
_fechaConst = _Solicitud.DataFaseII.First().FechaRegeneracion.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z";
|
|
_fechaFin = _Solicitud.DataFaseII.First().FechaFin.Value.ToString("yyyy-MM-dd") + "T06:00:00.0000Z";
|
|
_frecuencia = "M";
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 9");
|
|
|
|
_monto = _SegCotizacion.Monto.ToString();
|
|
_sucursal = _Solicitud.IdSucursal.ToString();
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 10");
|
|
|
|
_codigoExterno = "";
|
|
_porcentajeRecarVida = "0";
|
|
_porcentajeRecarItp = "0";
|
|
|
|
xmlString = xmlString.Replace("<dto:aseguradora></dto:aseguradora>", string.Format("<dto:aseguradora>{0}</dto:aseguradora>", _Aseguradora));
|
|
xmlString = xmlString.Replace("<dto:numOperacion></dto:numOperacion>", string.Format("<dto:numOperacion>{0}</dto:numOperacion>", _NumOperacion));
|
|
xmlString = xmlString.Replace("<dto:tipoRubro></dto:tipoRubro>", string.Format("<dto:tipoRubro>{0}</dto:tipoRubro>", _TipoRubro));
|
|
|
|
xmlString = xmlString.Replace("<dto:moneda></dto:moneda>", string.Format("<dto:moneda>{0}</dto:moneda>", _Moneda));
|
|
xmlString = xmlString.Replace("<dto:fechaConst></dto:fechaConst>", string.Format("<dto:fechaConst>{0}</dto:fechaConst>", _fechaConst));
|
|
xmlString = xmlString.Replace("<dto:fechaFin></dto:fechaFin>", string.Format("<dto:fechaFin>{0}</dto:fechaFin>", _fechaFin));
|
|
xmlString = xmlString.Replace("<dto:frecuencia></dto:frecuencia>", string.Format("<dto:frecuencia>{0}</dto:frecuencia>", _frecuencia));
|
|
|
|
xmlString = xmlString.Replace("<dto:monto></dto:monto>", string.Format("<dto:monto>{0}</dto:monto>", _monto));
|
|
xmlString = xmlString.Replace("<dto:sucursal></dto:sucursal>", string.Format("<dto:sucursal>{0}</dto:sucursal>", _sucursal));
|
|
xmlString = xmlString.Replace("<dto:codigoExterno></dto:codigoExterno>", string.Format("<dto:codigoExterno>{0}</dto:codigoExterno>", _codigoExterno));
|
|
xmlString = xmlString.Replace("<dto:porcentajeRecarVida></dto:porcentajeRecarVida>", string.Format("<dto:porcentajeRecarVida>{0}</dto:porcentajeRecarVida>", _porcentajeRecarVida));
|
|
xmlString = xmlString.Replace("<dto:porcentajeRecarItp></dto:porcentajeRecarItp>", string.Format("<dto:porcentajeRecarItp>{0}</dto:porcentajeRecarItp>", _porcentajeRecarItp));
|
|
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 11 => " + xmlString);
|
|
|
|
resp = interfaces.RegistrarSeguro(new ServiciosCobisCarteraPrendario.RegistrarSeguroRequest()
|
|
{
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario.ToString(),
|
|
Solicitud = req.IdSolicitud.ToString(),
|
|
strXML = xmlString,
|
|
Usuario = req.UserId,
|
|
TipoSeguro = _TipoRubro
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
throw new Exception("No se pudo obtener la respuesta del registro seguros en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ObtenerCalculoEndeudamiento
|
|
[HttpGet]
|
|
public JsonCalculoEndeudamientoResponse ObtenerCalculoEndeudamiento(int IdSolicitud, int IdCliente, int IdMoneda, decimal TipoCambio)
|
|
{
|
|
#region Variables/Objetos
|
|
|
|
ReferenciaDeudaAPIController refDeudas = null;
|
|
InfoLaboralAPIController infoLaboral = null;
|
|
JsonCalculoEndeudamientoResponse respuesta = null;
|
|
|
|
decimal dblCuotaPrestamo = 0;
|
|
decimal dblTotalCompromisosCliente = 0;
|
|
decimal dblTotalIngresosNetosCliente = 0;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
#region Inicializa Objetos
|
|
|
|
respuesta = new JsonCalculoEndeudamientoResponse();
|
|
refDeudas = new ReferenciaDeudaAPIController();
|
|
infoLaboral = new InfoLaboralAPIController();
|
|
|
|
#endregion
|
|
|
|
#region ObtenerDeudasCliente
|
|
var respDeudasCliente = refDeudas.ObtenerDeudasCliente(IdSolicitud, IdCliente, IdMoneda, TipoCambio, true);
|
|
|
|
if (respDeudasCliente.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respDeudasCliente.DescripcionRespuesta);
|
|
}
|
|
|
|
dblTotalCompromisosCliente = (decimal)respDeudasCliente.TotalDeudas;
|
|
|
|
#endregion
|
|
|
|
#region ObtenerInfoIngresosClinte
|
|
var respInfoIngresos = infoLaboral.ObtenerInfoIngresosClinte(IdSolicitud, IdCliente, TipoCambio, IdMoneda, true);
|
|
|
|
if (respInfoIngresos.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respInfoIngresos.DescripcionRespuesta);
|
|
}
|
|
|
|
dblTotalIngresosNetosCliente = respInfoIngresos.TotalIngresosNetos;
|
|
|
|
#endregion
|
|
|
|
#region ObtenerCuotaPrestamo
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
Solicitud _modelSolicitud = db.Solicitud
|
|
.Where(c => c.IdSolicitud == IdSolicitud)
|
|
.Include(c => c.Cotizacion)
|
|
.Include(c => c.Cotizacion.CondicionesTasaCotizacion)
|
|
.FirstOrDefault();
|
|
|
|
#region Ticket #2016062410001191
|
|
//************************************************************************
|
|
//BMU - 28-07-2016 - Ticket #2016062410001191
|
|
//Modificación para obtener la cuota del ultimo periodo de tasa escalonada
|
|
//************************************************************************
|
|
//CondicionesTasaCotizacion UltimoPeriodoCondicionesTasa = _modelSolicitud.Cotizacion.CondicionesTasaCotizacion.OrderByDescending(x => x.Periodo).FirstOrDefault();
|
|
//dblCuotaPrestamo = Convert.ToDecimal(new CotizacionAPIController().CalculaCuotaBase((double)((UltimoPeriodoCondicionesTasa.TasaReferencia + UltimoPeriodoCondicionesTasa.Spread) / 100), _modelSolicitud.Cotizacion.PeriodoMesesCredito.Value, (double)_modelSolicitud.Cotizacion.MontoPrestamo));
|
|
|
|
//************************************************************************
|
|
//BMU - 28-07-2016 - Ticket #2016062410001191
|
|
//Modificación para obtener la cuota del ultimo periodo de tasa escalonada
|
|
//************************************************************************
|
|
dblCuotaPrestamo = _modelSolicitud.Cotizacion.CuotaPrestamo == null ? 0 : _modelSolicitud.Cotizacion.CuotaPrestamo.Value;
|
|
//************************************************************************
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Calculo Endeudamiento
|
|
|
|
respuesta.Endeudamiento = Math.Round(((dblTotalCompromisosCliente + dblCuotaPrestamo) / dblTotalIngresosNetosCliente), 6);
|
|
|
|
#endregion
|
|
|
|
#region Calculo Cuota Ingreso
|
|
|
|
var respCalcCuotaIngreso = ObtenerCalculoCuotaIngreso(dblCuotaPrestamo, dblTotalIngresosNetosCliente);
|
|
if (respCalcCuotaIngreso.CodigoRespuesta != "EXITOSO")
|
|
throw new Exception(respCalcCuotaIngreso.DescripcionRespuesta);
|
|
|
|
respuesta.CuotaIngreso = respCalcCuotaIngreso.CuotaIngreso;
|
|
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
|
|
public JsonCalculoEndeudamientoResponse ObtenerCalculoEndeudamiento(int IdSolicitud, int IdCliente, int IdMoneda, decimal TipoCambio, decimal CuotaPrestamo, decimal TotalIngresosNetosCliente)
|
|
{
|
|
#region Variables/Objetos
|
|
|
|
ReferenciaDeudaAPIController refDeudas = null;
|
|
InfoLaboralAPIController infoLaboral = null;
|
|
JsonCalculoEndeudamientoResponse respuesta = null;
|
|
decimal decTotalCompromisosCliente = 0;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
#region Inicializa Objetos
|
|
|
|
respuesta = new JsonCalculoEndeudamientoResponse();
|
|
refDeudas = new ReferenciaDeudaAPIController();
|
|
infoLaboral = new InfoLaboralAPIController();
|
|
|
|
#endregion
|
|
|
|
#region ObtenerDeudasCliente
|
|
var respDeudasCliente = refDeudas.ObtenerDeudasCliente(IdSolicitud, IdCliente, IdMoneda, TipoCambio, true);
|
|
|
|
if (respDeudasCliente.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respDeudasCliente.DescripcionRespuesta);
|
|
}
|
|
|
|
decTotalCompromisosCliente = (decimal)respDeudasCliente.TotalDeudas;
|
|
|
|
#endregion
|
|
|
|
#region Calculo Endeudamiento
|
|
|
|
respuesta.Endeudamiento = Math.Round(((decTotalCompromisosCliente + CuotaPrestamo) / TotalIngresosNetosCliente), 6);
|
|
|
|
#endregion
|
|
|
|
#region Calculo Cuota Ingreso
|
|
|
|
var respCalcCuotaIngreso = ObtenerCalculoCuotaIngreso(CuotaPrestamo, TotalIngresosNetosCliente);
|
|
if (respCalcCuotaIngreso.CodigoRespuesta != "EXITOSO")
|
|
throw new Exception(respCalcCuotaIngreso.DescripcionRespuesta);
|
|
|
|
respuesta.CuotaIngreso = respCalcCuotaIngreso.CuotaIngreso;
|
|
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ObtenerCalculoCuotaIngreso
|
|
[HttpGet]
|
|
public JsonCalculoCuotaIngresoResponse ObtenerCalculoCuotaIngreso(int IdSolicitud, int IdCliente, int IdMoneda, decimal TipoCambio)
|
|
{
|
|
|
|
#region Variables/Objetos
|
|
|
|
InfoLaboralAPIController infoLaboral = null;
|
|
JsonCalculoCuotaIngresoResponse respuesta = null;
|
|
|
|
decimal dblCuotaPrestamo = 0;
|
|
decimal dblTotalIngresosNetosCliente = 0;
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
#region Inicializa Objetos
|
|
|
|
respuesta = new JsonCalculoCuotaIngresoResponse();
|
|
infoLaboral = new InfoLaboralAPIController();
|
|
|
|
#endregion
|
|
|
|
#region ObtenerInfoIngresosClinte
|
|
var respInfoIngresos = infoLaboral.ObtenerInfoIngresosClinte(IdSolicitud, IdCliente, TipoCambio, IdMoneda, true);
|
|
|
|
if (respInfoIngresos.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respInfoIngresos.DescripcionRespuesta);
|
|
}
|
|
|
|
dblTotalIngresosNetosCliente = respInfoIngresos.TotalIngresosNetos;
|
|
|
|
#endregion
|
|
|
|
#region ObtenerCuotaPrestamo
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
Solicitud _modelSolicitud = db.Solicitud
|
|
.Where(c => c.IdSolicitud == IdSolicitud)
|
|
.Include(c => c.Cotizacion)
|
|
.Include(c => c.Cotizacion.CondicionesTasaCotizacion)
|
|
.FirstOrDefault();
|
|
|
|
#region Ticket #2016062410001191
|
|
//************************************************************************
|
|
//BMU - 28-07-2016 - Ticket #2016062410001191
|
|
//Modificación para obtener la cuota del ultimo periodo de tasa escalonada
|
|
//************************************************************************
|
|
//CondicionesTasaCotizacion UltimoPeriodoCondicionesTasa = _modelSolicitud.Cotizacion.CondicionesTasaCotizacion.OrderByDescending(x => x.Periodo).FirstOrDefault();
|
|
//dblCuotaPrestamo = Convert.ToDecimal(new CotizacionAPIController().CalculaCuotaBase((double)((UltimoPeriodoCondicionesTasa.TasaReferencia + UltimoPeriodoCondicionesTasa.Spread) / 100), _modelSolicitud.Cotizacion.PeriodoMesesCredito.Value, (double)_modelSolicitud.Cotizacion.MontoPrestamo));
|
|
|
|
//************************************************************************
|
|
//BMU - 28-07-2016 - Ticket #2016062410001191
|
|
//Modificación para obtener la cuota del ultimo periodo de tasa escalonada
|
|
//************************************************************************
|
|
dblCuotaPrestamo = _modelSolicitud.Cotizacion.CuotaPrestamo == null ? 0 : _modelSolicitud.Cotizacion.CuotaPrestamo.Value;
|
|
//************************************************************************
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CalculoCuotaIngreso
|
|
|
|
respuesta.CuotaIngreso = Math.Round((dblCuotaPrestamo / dblTotalIngresosNetosCliente), 6);
|
|
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
public JsonCalculoCuotaIngresoResponse ObtenerCalculoCuotaIngreso(decimal CuotaPrestamo, decimal TotalIngresosNetosCliente)
|
|
{
|
|
#region Variables/Objetos
|
|
|
|
JsonCalculoCuotaIngresoResponse respuesta = null;
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
#region Inicializa Objetos
|
|
|
|
respuesta = new JsonCalculoCuotaIngresoResponse();
|
|
|
|
#endregion
|
|
|
|
#region CalculoCuotaIngreso
|
|
|
|
respuesta.CuotaIngreso = Math.Round((CuotaPrestamo / TotalIngresosNetosCliente), 6);
|
|
|
|
#endregion
|
|
|
|
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;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ConsultarOficialNombre
|
|
[HttpGet]
|
|
public JsonConsultarOficialNombreResponse ConsultarOficialNombre(int IdSucursal, string NombreOficial, string Proceso, string Usuario)
|
|
{
|
|
InterfacesAPIController interfaces = null;
|
|
JsonConsultarOficialNombreResponse respuesta = null;
|
|
MSXML2.DOMDocument xmlRespuesta = new DOMDocument();
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonConsultarOficialNombreResponse();
|
|
respuesta.oficiales = new List<JsonConsultarOficialNombre>();
|
|
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
#region ObtenerInfoOficiales
|
|
|
|
var respOficiales = interfaces.ConsultarOficialNombre(new ConsultarOficialNombreRequest()
|
|
{
|
|
CoSucursal = IdSucursal.ToString(),
|
|
NombreOficial = NombreOficial,
|
|
Proceso = ServiciosCobisConsultaGeneral.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|
UserName = Usuario
|
|
});
|
|
|
|
|
|
if (respOficiales.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respOficiales.errMessage);
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
if (string.IsNullOrEmpty(respOficiales.resultado))
|
|
{
|
|
throw new Exception("No se pudo recuperar el resultado de la consulta de oficiles.");
|
|
}
|
|
|
|
|
|
xmlRespuesta.loadXML(respOficiales.resultado);
|
|
|
|
if (xmlRespuesta.selectSingleNode("//Resultado/Oficiales") != null)
|
|
{
|
|
foreach (MSXML2.IXMLDOMNode nodoOficial in xmlRespuesta.selectSingleNode("//Resultado/Oficiales").childNodes)
|
|
{
|
|
|
|
JsonConsultarOficialNombre oficial = new JsonConsultarOficialNombre()
|
|
{
|
|
codigo = nodoOficial.selectSingleNode("CODIGO").text,
|
|
descripcion = nodoOficial.selectSingleNode("NOMBRE").text,
|
|
login = nodoOficial.selectSingleNode("LOGIN").text
|
|
};
|
|
|
|
respuesta.oficiales.Add(oficial);
|
|
}
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ObtenerNivelCapacidadPagoDeudor
|
|
[HttpGet]
|
|
public JsonCalculoNivelCapacidadPagoResponse ObtenerNivelCapacidadPagoDeudor(int IdSolicitud, int IdCliente, int IdMoneda, decimal TipoCambio)
|
|
{
|
|
|
|
InterfacesAPIController oInterface = null;
|
|
InfoLaboralAPIController infoLaboral = null;
|
|
JsonCalculoNivelCapacidadPagoResponse respuesta = null;
|
|
|
|
|
|
decimal decTotalIngresosNetosColones = 0;
|
|
decimal decTotalIngresosNetosDolares = 0;
|
|
decimal decEndeudamiento = 0;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonCalculoNivelCapacidadPagoResponse();
|
|
oInterface = new InterfacesAPIController();
|
|
infoLaboral = new InfoLaboralAPIController();
|
|
|
|
|
|
|
|
#region ObtenerInfoIngresosCliente
|
|
var respInfoIngresos = infoLaboral.ObtenerInfoIngresosClinte(IdSolicitud, IdCliente, TipoCambio, IdMoneda, true);
|
|
|
|
if (respInfoIngresos.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respInfoIngresos.DescripcionRespuesta);
|
|
}
|
|
|
|
decTotalIngresosNetosColones = respInfoIngresos.TotalIngresosNetosColones;
|
|
decTotalIngresosNetosDolares = respInfoIngresos.TotalIngresosNetosDolares;
|
|
|
|
#endregion
|
|
|
|
|
|
var respEndeudamiento = this.ObtenerCalculoEndeudamiento(IdSolicitud, IdCliente, IdMoneda, TipoCambio);
|
|
|
|
if (respEndeudamiento.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respEndeudamiento.DescripcionRespuesta);
|
|
}
|
|
|
|
decEndeudamiento = respEndeudamiento.Endeudamiento;
|
|
|
|
|
|
var resp = oInterface.ObtenerNivelCapacidadPagoDeudor(new ObtenerNivelCapacidadPagoDeudorRequest()
|
|
{
|
|
IdMoneda = IdMoneda,
|
|
IngresoNetoColones = (double)decTotalIngresosNetosColones,
|
|
IngresoNetoDolares = (double)decTotalIngresosNetosDolares,
|
|
PorcEndeudamiento = decEndeudamiento,
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|
TasaCambio = (double)TipoCambio
|
|
});
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
|
|
respuesta.NivelCapacidadPago = resp.NivelCapacidadPago;
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region ClasificaGeneradorMoneda
|
|
[HttpGet]
|
|
public JsonClasificaGeneradorMonedaResponse ClasificaGeneradorMoneda(int IdSolicitud, int IdCliente, string DescripcionMoneda, decimal TipoCambio)
|
|
{
|
|
|
|
InterfacesAPIController oInterface = null;
|
|
InfoLaboralAPIController infoLaboral = null;
|
|
JsonClasificaGeneradorMonedaResponse respuesta = null;
|
|
|
|
|
|
decimal decTotalIngresosNetosColones = 0;
|
|
decimal decTotalIngresosNetosDolares = 0;
|
|
decimal decCuotaPrestamo = 0;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonClasificaGeneradorMonedaResponse();
|
|
oInterface = new InterfacesAPIController();
|
|
infoLaboral = new InfoLaboralAPIController();
|
|
|
|
|
|
#region ObtenerInfoIngresosCliente
|
|
var respInfoIngresos = infoLaboral.ObtenerInfoIngresosClinte(IdSolicitud, IdCliente, TipoCambio, null, true);
|
|
|
|
if (respInfoIngresos.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(respInfoIngresos.DescripcionRespuesta);
|
|
}
|
|
|
|
decTotalIngresosNetosColones = respInfoIngresos.TotalIngresosNetosColones;
|
|
decTotalIngresosNetosDolares = respInfoIngresos.TotalIngresosNetosDolares;
|
|
|
|
#endregion
|
|
|
|
|
|
#region CuotaPrestamo
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
Solicitud _modelSolicitud = db.Solicitud.Include(c => c.Cotizacion).Where(c => c.IdSolicitud == IdSolicitud).FirstOrDefault();
|
|
decCuotaPrestamo = _modelSolicitud.Cotizacion.CuotaPrestamo == null ? 0 : _modelSolicitud.Cotizacion.CuotaPrestamo.Value;
|
|
}
|
|
#endregion
|
|
|
|
|
|
var resp = oInterface.ClasificaGeneradorMoneda(new ClasificaGeneradorMonedaRequest()
|
|
{
|
|
CuotaPrestamo = decCuotaPrestamo.ToString(),
|
|
IdCliente = IdCliente.ToString(),
|
|
IdSolicitud = IdSolicitud.ToString(),
|
|
Moneda = DescripcionMoneda,
|
|
Proceso = WCFServiciosGenerales.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|
TasaCambio = TipoCambio.ToString(),
|
|
TotalIngresoNetoColones = decTotalIngresosNetosColones.ToString(),
|
|
TotalIngresoNetoDolares = decTotalIngresosNetosDolares.ToString(),
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
respuesta.CategoriaGenerador = resp.CategoriaGenerador;
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerRubroSeguro
|
|
private List<JsonCatalogos> ObtenerRubroSeguro(EnumTipoRubroSeguro enumTipoRubroSeguro, string filtro)
|
|
{
|
|
List<JsonCatalogos> ret = new List<JsonCatalogos>();
|
|
List<RubroSeguro> list = new List<RubroSeguro>();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(filtro))
|
|
list = db.RubroSeguro.Where(e => e.IdTipoRubroSeguro == (int)enumTipoRubroSeguro && e.Estado == true).ToList();
|
|
else
|
|
list = db.RubroSeguro.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|
&& e.IdTipoRubroSeguro == (int)enumTipoRubroSeguro && e.Estado == true).ToList();
|
|
|
|
foreach (var ele in list)
|
|
{
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|
catalogo.codigo = ele.IdRubroSeguro.ToString().Trim();
|
|
catalogo.descripcion = ele.Descripcion.ToString().Trim();
|
|
ret.Add(catalogo);
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ObtenerFechaProcesoCobis
|
|
[HttpPost]
|
|
public JsonFechaProcesoCobis ObtenerFechaProcesoCobis(JsonRegistrarTasaEscalonadaRequest req)
|
|
{
|
|
JsonFechaProcesoCobis respuesta = null;
|
|
InterfacesAPIController interfaces = null;
|
|
ServiciosCobisConsultaGeneral.ConsultarFechaProcesoCobisResponse resp = null;
|
|
|
|
try
|
|
{
|
|
respuesta = new JsonFechaProcesoCobis();
|
|
interfaces = new InterfacesAPIController();
|
|
|
|
using (PrendarioContext db = new PrendarioContext())
|
|
{
|
|
|
|
resp = interfaces.ConsultarFechaProcesoCobis(new ServiciosCobisConsultaGeneral.ConsultarFechaProcesoCobisRequest()
|
|
{
|
|
Proceso = ServiciosCobisConsultaGeneral.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|
UserName = req.UserId
|
|
});
|
|
|
|
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
throw new Exception(resp.errMessage);
|
|
}
|
|
|
|
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|
{
|
|
throw new Exception("No se pudo obtener la respuesta del registro seguros en cobis. Por favor comuniquese con el Administrador del Sistema.");
|
|
}
|
|
|
|
respuesta.FechaProceso = resp.FechaProceso;
|
|
|
|
}
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
respuesta.Alertas.Add(ex.Message);
|
|
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|