130 lines
No EOL
4.7 KiB
C#
130 lines
No EOL
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Http;
|
|
using ULA.Cathay.Credito.Json;
|
|
using ULA.Cathay.Credito.ServicioSAP;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using ULA.Cathay.CreditoModel.DAL.Credito;
|
|
using ULA.Cathay.CreditoModel.Entidades;
|
|
using Ultimus.Interfaces;
|
|
using Ultimus.Utilitarios;
|
|
|
|
namespace ULA.Cathay.Credito.ControllersWebApi.Desembolso
|
|
{
|
|
public class TransferirOfertaContratoDeAPIController : ApiController
|
|
{
|
|
UltimusLogs logs = new UltimusLogs("TransferirOfertaContratoDeAPIController");
|
|
|
|
public TransferirOfertaContratoDeAPIController()
|
|
{
|
|
GlobalAPIController.SetRegionalConfig();
|
|
}
|
|
|
|
#region InsertarActualizar
|
|
[HttpPost]
|
|
public DesembolsoJSON InsertarActualizar(DesembolsoJSON model)
|
|
{
|
|
|
|
DesembolsoDatosGeneralesDAL DesembolsoDatosGeneralesDal = new DesembolsoDatosGeneralesDAL();
|
|
ProcesosDAL ProcesosDal = new ProcesosDAL();
|
|
Procesos Desembolso;
|
|
DesembolsoDatosGenerales mDesembolsoDatosGenerales;
|
|
|
|
try
|
|
{
|
|
Desembolso = ProcesosDal.Obtener(EnumProcesos.Desembolso);
|
|
mDesembolsoDatosGenerales = model.Solicitud.DesembolsoDatosGenerales;
|
|
model.Solicitud.ClearVirtualProperties();
|
|
|
|
if (mDesembolsoDatosGenerales != null)
|
|
{
|
|
DesembolsoDatosGeneralesDal.InsertarActualizar(mDesembolsoDatosGenerales);
|
|
}
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerGarantia
|
|
public List<Garantia> ObtenerGarantia(String CodigoBP, string NumeroLinea)
|
|
{
|
|
List<Garantia> respuesta = new List<Garantia>();
|
|
SolicitanteDAL ObjSolicitanteDAL = new SolicitanteDAL();
|
|
Solicitante ObjSolicitante = new Solicitante();
|
|
SAPServicioIntegracionAPIController SAP = new SAPServicioIntegracionAPIController();
|
|
List<Lineas> LineasCliente;
|
|
DatosEntrada DatosSAP = new DatosEntrada();
|
|
try
|
|
{
|
|
|
|
DatosSAP.NumeroCliente = CodigoBP;
|
|
LineasCliente = SAP.ConsultaLineasCliente(DatosSAP);
|
|
foreach (var l in LineasCliente)
|
|
{
|
|
if (l.NumeroLinea == NumeroLinea)
|
|
{
|
|
string[] MtzGarantia = l.Garantias.Split(';');
|
|
for (int g = 0; g < MtzGarantia.Length; g++)
|
|
{
|
|
Garantia garantia = new Garantia();
|
|
garantia.Descripcion = MtzGarantia[g];
|
|
respuesta.Add(garantia);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
#region Cargar
|
|
[HttpGet]
|
|
public DesembolsoJSON Cargar(int IdSolicitud)
|
|
{
|
|
DesembolsoJSON model = new DesembolsoJSON();
|
|
SolicitudDAL SolicitudDal = new SolicitudDAL();
|
|
DesembolsoDatosGeneralesDAL DesembolsoDatosGeneralesDal = new DesembolsoDatosGeneralesDAL();
|
|
SolicitanteDAL SolicitanteDal = new SolicitanteDAL();
|
|
string CodigoBP = string.Empty;
|
|
try
|
|
{
|
|
|
|
model.Solicitud = SolicitudDal.Obtener(IdSolicitud);
|
|
|
|
if (model.Solicitud != null)
|
|
{
|
|
model.Solicitud.Solicitante = SolicitanteDal.ObtenerSolicitantes(IdSolicitud);
|
|
model.Solicitud.DesembolsoDatosGenerales = DesembolsoDatosGeneralesDal.Obtener(IdSolicitud);
|
|
Solicitante Solicitante = model.Solicitud.Solicitante.Where(x => x.EsPrincipal == true).FirstOrDefault();
|
|
|
|
if (Solicitante != null)
|
|
CodigoBP = Solicitante.Cliente.CodigoBP;
|
|
|
|
model.ListGaranti = ObtenerGarantia(CodigoBP, model.Solicitud.DesembolsoDatosGenerales.NumeroLinea);
|
|
}
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return model;
|
|
}
|
|
#endregion
|
|
}
|
|
} |