201 lines
No EOL
7.3 KiB
C#
201 lines
No EOL
7.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Http;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using Ultimus.Interfaces;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Cathay.CreditoModel.DAL.Credito;
|
|
using ULA.Cathay.CreditoModel.CorporativoDatosRecientes;
|
|
using ULA.Cathay.CreditoModel.DAL.CorporativoDatosRecientes;
|
|
|
|
|
|
namespace ULA.Cathay.Credito.ControllersWebApi
|
|
{
|
|
public partial class IngresoClienteAPIController : ApiController
|
|
{
|
|
|
|
private UltimusLogs logs = new UltimusLogs("IngresoClienteAPIController");
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="filtro"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public List<JsonCatalogos> OpcionesValoresCriterioSeleccion(string filtro = null, int? id = null, int? id2 = null)
|
|
{
|
|
HojaSeleccionDAL Conn = new HojaSeleccionDAL();
|
|
List<JsonCatalogos> respuesta = new List<JsonCatalogos>();
|
|
|
|
try
|
|
{
|
|
respuesta = Conn.OpcionesValoresCriterioSeleccion(filtro, id, id2);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
Conn = null;
|
|
}
|
|
return respuesta;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public List<HojaSeleccion> ObtenerValorCriteriosSolicitud(HojaSeleccion model)
|
|
{
|
|
List<HojaSeleccion> respuesta = new List<HojaSeleccion>();
|
|
HojaSeleccionDAL Conn = new HojaSeleccionDAL();
|
|
List<ClienteCriteriosSeleccion> DatosActual = new List<ClienteCriteriosSeleccion>();
|
|
ClienteCriteriosSeleccion modelDatosActual = new ClienteCriteriosSeleccion();
|
|
ClienteCriteriosSeleccionDal ConnDatosActual = new ClienteCriteriosSeleccionDal();
|
|
SolicitanteDAL ConnSolicitante = new SolicitanteDAL();
|
|
Solicitante Deudor = new Solicitante();
|
|
|
|
try
|
|
{
|
|
respuesta = Conn.ObtenerValorCriteriosSolicitud(model);
|
|
|
|
if (respuesta.Where(p => !string.IsNullOrWhiteSpace(p.ValorCriterio)).Count() == 0)
|
|
{
|
|
Deudor = ConnSolicitante.Obtener(model.IdSolicitud).Where(q => q.EsPrincipal == true).FirstOrDefault();
|
|
modelDatosActual.NumeroIdentificacion = Deudor.Cliente.NumeroIdentificacion;
|
|
modelDatosActual.IdTipoIdentificacion = Deudor.Cliente.IdTipoIdentificacion.Value;
|
|
DatosActual = ConnDatosActual.ObtenerValorCriteriosSolicitud(modelDatosActual);
|
|
if (DatosActual.Count > 0)
|
|
{
|
|
foreach (HojaSeleccion ObjCriterio in respuesta.Where(p => string.IsNullOrWhiteSpace(p.ValorCriterio)))
|
|
{
|
|
modelDatosActual = DatosActual.Where(q => q.IdCriterioSeleccion == ObjCriterio.IdCriterioSeleccion).FirstOrDefault();
|
|
if (string.IsNullOrWhiteSpace(ObjCriterio.ValorCriterio) && modelDatosActual != null)
|
|
{
|
|
ObjCriterio.IdTipoSeleccion = modelDatosActual.IdTipoSeleccion;
|
|
ObjCriterio.ValorCriterio = modelDatosActual.ValorCriterio;
|
|
if (modelDatosActual.IdMoneda != null)
|
|
{
|
|
ObjCriterio.Monto = modelDatosActual.Monto;
|
|
ObjCriterio.IdMoneda = modelDatosActual.IdMoneda;
|
|
ObjCriterio.MontoEquivalente = modelDatosActual.MontoEquivalente;
|
|
ObjCriterio.Moneda = new Moneda() { IdMoneda = modelDatosActual.IdMoneda.Value, Descripcion = modelDatosActual.DescripcionMoneda };
|
|
}
|
|
model.CopyValueProperties(modelDatosActual);
|
|
model.Moneda = null;
|
|
model.CriterioSeleccion = null;
|
|
model.MatrizSeleccion = null;
|
|
GuardarValorCriteriosSolicitud(model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
Conn = null;
|
|
DatosActual = null;
|
|
modelDatosActual = null;
|
|
ConnDatosActual = null;
|
|
ConnSolicitante = null;
|
|
Deudor = null;
|
|
}
|
|
|
|
return respuesta;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public BaseJson GuardarValorCriteriosSolicitud(HojaSeleccion model)
|
|
{
|
|
HojaSeleccionDAL Conn = new HojaSeleccionDAL();
|
|
BaseJson ValorRetorno = new BaseJson();
|
|
|
|
try
|
|
{
|
|
ValorRetorno= Conn.InsertarActualizar(model);
|
|
|
|
if (ValorRetorno.CodigoRespuesta == TipoCodigoRespuesta.EXITOSO.ToString())
|
|
Conn.EliminarDatosCriteriosRelacion(model);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
ValorRetorno.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
finally
|
|
{
|
|
Conn = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public BaseJson EliminarValorCriteriosSolicitud(HojaSeleccion model)
|
|
{
|
|
HojaSeleccionDAL Conn = new HojaSeleccionDAL();
|
|
BaseJson ValorRetorno = new BaseJson();
|
|
|
|
try
|
|
{
|
|
ValorRetorno = Conn.EliminarDatos(model);
|
|
|
|
if (ValorRetorno.CodigoRespuesta == TipoCodigoRespuesta.EXITOSO.ToString())
|
|
Conn.EliminarDatosCriteriosRelacion(model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
ValorRetorno.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
finally
|
|
{
|
|
Conn = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public List<MatrizSeleccionRelacion> ObtenerMatrizSeleccionRelacion()
|
|
{
|
|
MatrizSeleccionRelacionDAL ConnMtz = new MatrizSeleccionRelacionDAL();
|
|
List<MatrizSeleccionRelacion> ListaMatrizSeleccionRelacion = new List<MatrizSeleccionRelacion>();
|
|
|
|
try
|
|
{
|
|
ListaMatrizSeleccionRelacion = ConnMtz.Obtener().Where(x => x.Estado == true).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
ListaMatrizSeleccionRelacion = null;
|
|
}
|
|
finally
|
|
{
|
|
}
|
|
|
|
return ListaMatrizSeleccionRelacion;
|
|
}
|
|
|
|
}
|
|
} |