458 lines
27 KiB
C#
458 lines
27 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data.Entity.Validation;
|
|||
|
|
using System.Data.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Web.Http;
|
|||
|
|
using ULA.Davivienda.PrendarioModel;
|
|||
|
|
using ULA.Davivienda.PrendarioModel.Prendario;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Commons;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.CotizadorServiceLayer;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Json;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFPrendarioSeguros;
|
|||
|
|
using Ultimus.Utilitarios;
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class SegurosAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Crypt crypt = new Crypt();
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ObtenerPeriodoReajuste
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonCatalogos> ObtenerPeriodoReajuste(string filtro = null, string codigo = null)
|
|||
|
|
{
|
|||
|
|
List<JsonCatalogos> listaPeriodoReajuste = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
listaPeriodoReajuste = new List<JsonCatalogos>();
|
|||
|
|
List<PeriodoReajuste> PeriodoReajuste = new List<PeriodoReajuste>();
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrWhiteSpace(filtro))
|
|||
|
|
PeriodoReajuste = db.PeriodoReajuste.Where(e => e.Descripcion.Trim().ToLower().Contains(filtro.Trim().ToLower()) == true
|
|||
|
|
&& e.Estado == true).ToList();
|
|||
|
|
|
|||
|
|
else if (!string.IsNullOrWhiteSpace(codigo))
|
|||
|
|
PeriodoReajuste = db.PeriodoReajuste.Where(e => e.IdPeriodoReajuste.Trim().ToLower().Contains(codigo.Trim().ToLower()) == true
|
|||
|
|
&& e.Estado == true).ToList();
|
|||
|
|
else
|
|||
|
|
PeriodoReajuste = db.PeriodoReajuste.Where(e => e.Estado == true).ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (var n in PeriodoReajuste)
|
|||
|
|
{
|
|||
|
|
JsonCatalogos catalogo = new JsonCatalogos();
|
|||
|
|
catalogo.codigo = n.IdPeriodoReajuste.ToString().Trim();
|
|||
|
|
catalogo.descripcion = n.Descripcion.ToString().Trim();
|
|||
|
|
listaPeriodoReajuste.Add(catalogo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return listaPeriodoReajuste;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonSolicitud getDataModel(int _IdSolicitud, string etapa)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
JsonSolicitud resp = new JsonSolicitud();
|
|||
|
|
CotizacionAPIController cotApiController = new CotizacionAPIController();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
resp.Solicitud = (from s in db.Solicitud
|
|||
|
|
.Include(e => e.Garantia)
|
|||
|
|
where s.IdSolicitud == _IdSolicitud
|
|||
|
|
select s).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
resp.Solicitante = (from sl in db.Solicitante
|
|||
|
|
.Include(e => e.Cliente)
|
|||
|
|
.Include(e => e.TipoSolicitante)
|
|||
|
|
where sl.IdSolicitud == resp.Solicitud.IdSolicitud
|
|||
|
|
select sl).ToList();
|
|||
|
|
|
|||
|
|
int IdEtapa = db.Etapas.Where(x => x.DescripcionEtapa.Trim() == etapa).FirstOrDefault().IdEtapa;
|
|||
|
|
|
|||
|
|
List<HistorialDecision> ListaHistorial = (from hd in db.HistorialDecision
|
|||
|
|
.Include(x => x.Decision)
|
|||
|
|
.Include(x => x.Motivo)
|
|||
|
|
where hd.IdSolicitud == _IdSolicitud && hd.IdEtapa == IdEtapa
|
|||
|
|
select hd).ToList();
|
|||
|
|
if (ListaHistorial.FirstOrDefault() != null)
|
|||
|
|
{
|
|||
|
|
int IdHistorial = ListaHistorial.Max(q => q.IdHistorialDecision);
|
|||
|
|
|
|||
|
|
resp.HistorialDecision = (from hd in ListaHistorial
|
|||
|
|
where hd.IdHistorialDecision == IdHistorial
|
|||
|
|
select hd).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
resp.DatosCotizacion = (from c in db.Cotizacion
|
|||
|
|
.Include(e => e.Campanna)
|
|||
|
|
.Include(e => e.ProgramaCrediticio)
|
|||
|
|
.Include(e => e.AnnoVehiculo)
|
|||
|
|
.Include(e => e.Moneda)
|
|||
|
|
.Include(e => e.TipoVehiculo)
|
|||
|
|
.Include(e => e.CondicionesTasaCotizacion)
|
|||
|
|
.Include(e => e.AgenciaVehiculo)
|
|||
|
|
.Include(e => e.SubAgenciaVehiculo)
|
|||
|
|
.Include(e => e.MarcaVehiculo)
|
|||
|
|
.Include(e => e.EstiloVehiculo)
|
|||
|
|
.Include(e => e.TipoFuenteIngreso)
|
|||
|
|
.Include(e => e.UsoVehiculo)
|
|||
|
|
.Include(e => e.SegurosCotizacion)
|
|||
|
|
.Include(e => e.EjecutivoCotizacion)
|
|||
|
|
where c.IdCotizacion == resp.Solicitud.IdCotizacion
|
|||
|
|
select new JsonDatosCotizacion
|
|||
|
|
{
|
|||
|
|
IdCotizacion = c.IdCotizacion,
|
|||
|
|
Campanna = c.Campanna,
|
|||
|
|
IdCampanna = c.Campanna.IdCampanna,
|
|||
|
|
DescripcionCampanna = c.Campanna.Descripcion,
|
|||
|
|
|
|||
|
|
ProgramaCrediticio = c.ProgramaCrediticio,
|
|||
|
|
IdProgramaCrediticio = c.IdProgramaCrediticio,
|
|||
|
|
DescripcionProgramaCrediticio = c.ProgramaCrediticio.Descripcion,
|
|||
|
|
|
|||
|
|
AnnoVehiculo = c.AnnoVehiculo,
|
|||
|
|
IdAnnoVehiculo = c.AnnoVehiculo.IdAnnoVehiculo,
|
|||
|
|
DescripcionAnnoVehiculo = c.AnnoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
Moneda = c.Moneda,
|
|||
|
|
IdMoneda = c.Moneda.IdMoneda,
|
|||
|
|
DescripcionMoneda = c.Moneda.Descripcion,
|
|||
|
|
|
|||
|
|
TipoVehiculo = c.TipoVehiculo,
|
|||
|
|
IdTipoVehiculo = c.TipoVehiculo.IdTipoVehiculo,
|
|||
|
|
DescripcionTipoVehiculo = c.TipoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
CondicionesTasaCotizacion = c.CondicionesTasaCotizacion,
|
|||
|
|
|
|||
|
|
AgenciaVehiculo = c.AgenciaVehiculo,
|
|||
|
|
IdAgenciaVehiculo = c.AgenciaVehiculo.IdAgenciaVehiculo,
|
|||
|
|
DescripcionAgenciaVehiculo = c.AgenciaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
SubAgenciaVehiculo = c.SubAgenciaVehiculo,
|
|||
|
|
IdSubAgenciaVehiculo = c.SubAgenciaVehiculo.IdSubAgenciaVehiculo,
|
|||
|
|
DescripcionSubAgenciaVehiculo = c.SubAgenciaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
MarcaVehiculo = c.MarcaVehiculo,
|
|||
|
|
IdMarcaVehiculo = c.MarcaVehiculo.IdMarcaVehiculo,
|
|||
|
|
DescripcionMarcaVehiculo = c.MarcaVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
EstiloVehiculo = c.EstiloVehiculo,
|
|||
|
|
IdEstiloVehiculo = c.EstiloVehiculo.IdEstiloVehiculo,
|
|||
|
|
DescripcionEstiloVehiculo = c.EstiloVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
TipoFuenteIngreso = c.TipoFuenteIngreso,
|
|||
|
|
IdFuenteIngreso = c.TipoFuenteIngreso.IdFuenteIngreso,
|
|||
|
|
DescripcionTipoFuenteIngreso = c.TipoFuenteIngreso.Descripcion,
|
|||
|
|
|
|||
|
|
UsoVehiculo = c.UsoVehiculo,
|
|||
|
|
IdUsoVehiculo = c.UsoVehiculo.IdUsoVehiculo,
|
|||
|
|
DescripcionUsoVehiculo = c.UsoVehiculo.Descripcion,
|
|||
|
|
|
|||
|
|
EsColaborador = c.EsColaborador,
|
|||
|
|
PorcComision = c.PorcComision,
|
|||
|
|
PorcPrimaMinima = c.PorcPrimaMinima,
|
|||
|
|
PeriodoMesesCredito = c.PeriodoMesesCredito,
|
|||
|
|
PeriodoMesesGracia = c.PeriodoMesesGracia,
|
|||
|
|
ValorVehiculo = c.ValorVehiculo,
|
|||
|
|
TipoCambio = c.TipoCambio,
|
|||
|
|
PorcPrima = c.PorcPrima,
|
|||
|
|
MontoPrima = c.MontoPrima,
|
|||
|
|
MontoComision = c.MontoComision,
|
|||
|
|
PorcIngresoMinReq = c.PorcIngresoMinReq,
|
|||
|
|
IngresoMinReqCol = c.IngresoMinReqCol,
|
|||
|
|
IngresoMInReqDol = c.IngresoMInReqDol,
|
|||
|
|
MontoPrestamo = c.MontoPrestamo,
|
|||
|
|
MontoPrestamoSinSeguros = c.MontoPrestamoSinSeguros,
|
|||
|
|
MontoDesembolso = c.MontoDesembolso,
|
|||
|
|
FeCotiza = c.FeCotiza,
|
|||
|
|
|
|||
|
|
TipoIdentificacion = c.TipoIdentificacion,
|
|||
|
|
IdTipoIdentificacion = c.TipoIdentificacion.IdTipoIdentificacion,
|
|||
|
|
DescripcionTipoIdentificacion = c.TipoIdentificacion.Descripcion,
|
|||
|
|
|
|||
|
|
Identificacion = c.Identificacion,
|
|||
|
|
PrimerNombre = c.PrimerNombre,
|
|||
|
|
SegundoNombre = c.SegundoNombre,
|
|||
|
|
PrimerApellido = c.PrimerApellido,
|
|||
|
|
SegundoApellido = c.SegundoApellido,
|
|||
|
|
Email = c.Email,
|
|||
|
|
EstadoCotiza = c.EstadoCotiza,
|
|||
|
|
|
|||
|
|
|
|||
|
|
SegurosCotizacion = c.SegurosCotizacion,
|
|||
|
|
|
|||
|
|
EjecutivoCotizacion = c.EjecutivoCotizacion,
|
|||
|
|
AplicaPolizaVehiculoGratis = c.AplicaPolizaVehiculoGratis,
|
|||
|
|
|
|||
|
|
}).ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (Solicitante z in resp.Solicitante)
|
|||
|
|
{
|
|||
|
|
z.Cliente = (from s in db.Cliente
|
|||
|
|
.Include(e => e.Genero)
|
|||
|
|
.Include(e => e.TipoIdentificacion)
|
|||
|
|
.Include(e => e.Profesion)
|
|||
|
|
.Include(e => e.Nacionalidad)
|
|||
|
|
where s.IdCliente == z.IdCliente
|
|||
|
|
select s).FirstOrDefault();
|
|||
|
|
|
|||
|
|
z.Cliente.DireccionCliente.Add((from s in db.DireccionCliente
|
|||
|
|
.Include(e => e.Provincia)
|
|||
|
|
.Include(e => e.Distrito)
|
|||
|
|
.Include(e => e.Distrito.Canton)
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoDireccion.Trim().Equals("DM")
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
|
|||
|
|
z.Cliente.TelefonoCliente.Add((from s in db.TelefonoCliente
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoTelefono.Trim().Equals("DM")
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
|
|||
|
|
|
|||
|
|
z.Cliente.EmailCliente.Add((from s in db.EmailCliente
|
|||
|
|
where s.IdCliente == z.IdCliente && s.IdTipoEmail == 1
|
|||
|
|
select s).FirstOrDefault());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (Garantia g in resp.Solicitud.Garantia)
|
|||
|
|
{
|
|||
|
|
g.TipoCombustible = db.TipoCombustible.Where(e => e.IdTipoCombustible == g.IdTipoCombustible).FirstOrDefault();
|
|||
|
|
g.TipoTraccion = db.TipoTraccion.Where(e => e.IdTipoTraccion == g.IdTipoTraccion).FirstOrDefault();
|
|||
|
|
g.TipoTransmision = db.TipoTransmision.Where(e => e.IdTipoTransmision == g.IdTipoTransmision).FirstOrDefault();
|
|||
|
|
g.CategoriaVehiculo = db.CategoriaVehiculo.Where(e => e.IdCategoriaVehiculo == g.IdCategoriaVehiculo).FirstOrDefault();
|
|||
|
|
g.CarroceriaVehiculo = db.CarroceriaVehiculo.Where(e => e.IdCarroceriaVehiculo == g.IdCarroceriaVehiculo).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (JsonDatosCotizacion x in resp.DatosCotizacion)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
foreach (SegurosCotizacion y in x.SegurosCotizacion)
|
|||
|
|
{
|
|||
|
|
y.RubroSeguro = db.RubroSeguro.Where(e => e.IdRubroSeguro == y.IdRubroSeguro).FirstOrDefault();
|
|||
|
|
y.RubroSeguro.Aseguradora = db.Aseguradora.Where(e => e.IdAseguradora == y.RubroSeguro.IdAseguradora).FirstOrDefault();
|
|||
|
|
y.RubroSeguro.TipoRubroSeguro = db.TipoRubroSeguro.Where(e => e.IdTipoRubroSeguro == y.RubroSeguro.IdTipoRubroSeguro).FirstOrDefault();
|
|||
|
|
y.AgenteSeguro = db.AgenteSeguro.Where(e => e.IdAgenteSeguro == y.IdAgenteSeguro).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach (CondicionesTasaCotizacion y in x.CondicionesTasaCotizacion)
|
|||
|
|
{
|
|||
|
|
y.TipoTasa = db.TipoTasa.Where(e => e.IdTipoTasa == y.IdTipoTasa).FirstOrDefault();
|
|||
|
|
y.TipoTasaReferencia = db.TipoTasaReferencia.Where(e => e.IdTipoTasaReferencia == y.IdTipoTasaReferencia).FirstOrDefault();
|
|||
|
|
y.PeriodoReajuste = db.PeriodoReajuste.Where(e => e.IdPeriodoReajuste == y.IdPeriodoReajuste).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
x.CondicionesTasaCotizacionAdapted = (from p in x.CondicionesTasaCotizacion
|
|||
|
|
select new JsonCondicionesTasaCotizacion()
|
|||
|
|
{
|
|||
|
|
DescripcionTipoTasa = p.TipoTasa.Descripcion,
|
|||
|
|
DescripcionTipoTasaReferencia = p.TipoTasaReferencia.Descripcion,
|
|||
|
|
DescripcionPeriodoReajuste = p.PeriodoReajuste.Descripcion,
|
|||
|
|
IdPeriodoReajuste = p.IdPeriodoReajuste,
|
|||
|
|
IdTipoTasa = p.IdTipoTasa,
|
|||
|
|
IdTipoTasaReferencia = p.IdTipoTasaReferencia,
|
|||
|
|
Periodo = p.Periodo,
|
|||
|
|
PeriodoReajuste = p.PeriodoReajuste,
|
|||
|
|
PlazoMeses = p.PlazoMeses,
|
|||
|
|
Spread = p.Spread,
|
|||
|
|
TasaMinima = p.TasaMinima,
|
|||
|
|
TasaReferencia = p.TasaReferencia,
|
|||
|
|
TipoTasa = p.TipoTasa,
|
|||
|
|
TipoTasaReferencia = p.TipoTasaReferencia,
|
|||
|
|
TasaInteresFinal = (p.TasaReferencia + p.Spread)
|
|||
|
|
|
|||
|
|
}).ToList();
|
|||
|
|
|
|||
|
|
x.EnunciadoCondiciones = cotApiController.GetEnunciadoCondiciones((from j in x.CondicionesTasaCotizacionAdapted
|
|||
|
|
select new JsonProgramaCrediticioCondicionesTasa()
|
|||
|
|
{
|
|||
|
|
DescripcionPeriodoReajuste = j.DescripcionPeriodoReajuste,
|
|||
|
|
DescripcionTipoTasa = j.DescripcionTipoTasa,
|
|||
|
|
DescripcionTipoTasaReferencia = j.DescripcionTipoTasaReferencia,
|
|||
|
|
IdPeriodoReajuste = j.IdPeriodoReajuste,
|
|||
|
|
IdTipoTasa = j.IdTipoTasa,
|
|||
|
|
IdTipoTasaReferencia = j.IdTipoTasaReferencia,
|
|||
|
|
Periodo = j.Periodo,
|
|||
|
|
PeriodoReajuste = j.PeriodoReajuste,
|
|||
|
|
PlazoMeses = j.PlazoMeses,
|
|||
|
|
Spread = j.Spread,
|
|||
|
|
TasaInteresFinal = j.TasaInteresFinal,
|
|||
|
|
TasaMinima = j.TasaMinima,
|
|||
|
|
TasaReferencia = j.TasaReferencia,
|
|||
|
|
TipoTasa = j.TipoTasa,
|
|||
|
|
TipoTasaReferencia = j.TipoTasaReferencia
|
|||
|
|
}).ToList(),
|
|||
|
|
(int)resp.DatosCotizacion.First().PeriodoMesesCredito
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = ex.Message;
|
|||
|
|
}
|
|||
|
|
return resp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region GuardarDatos
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonResponseBase GuardarDatos([FromBody] JsonSolicitud Model)
|
|||
|
|
{
|
|||
|
|
JsonResponseBase respuesta = new JsonResponseBase();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
Garantia _modelGarantiaInsUpdate = null;
|
|||
|
|
|
|||
|
|
#region SegurosCotizacion
|
|||
|
|
List<SegurosCotizacion> lisseguro = db.SegurosCotizacion.Where(q => q.IdCotizacion == Model.IdCotizacion).ToList();
|
|||
|
|
db.SegurosCotizacion.RemoveRange(lisseguro);
|
|||
|
|
db.SaveChanges();
|
|||
|
|
AgregarSegurosCotizacion(db, Model.IdCotizacion, Model.SegurosCotizacion);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Garantia
|
|||
|
|
_modelGarantiaInsUpdate = db.Garantia.Where(s => s.IdSolicitud == Model.Solicitud.IdSolicitud).FirstOrDefault();
|
|||
|
|
if (_modelGarantiaInsUpdate != null)
|
|||
|
|
{
|
|||
|
|
_modelGarantiaInsUpdate.Chasis = Model.Solicitud.Garantia.First().Chasis;
|
|||
|
|
_modelGarantiaInsUpdate.Motor = Model.Solicitud.Garantia.First().Motor;
|
|||
|
|
_modelGarantiaInsUpdate.Placa = Model.Solicitud.Garantia.First().Placa;
|
|||
|
|
_modelGarantiaInsUpdate.Color = Model.Solicitud.Garantia.First().Color;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoTraccion = Model.Solicitud.Garantia.First().IdTipoTraccion;
|
|||
|
|
_modelGarantiaInsUpdate.PesoNeto = Model.Solicitud.Garantia.First().PesoNeto;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoTransmision = Model.Solicitud.Garantia.First().IdTipoTransmision;
|
|||
|
|
_modelGarantiaInsUpdate.Cilindrada = Model.Solicitud.Garantia.First().Cilindrada;
|
|||
|
|
_modelGarantiaInsUpdate.NumCilindros = Model.Solicitud.Garantia.First().NumCilindros;
|
|||
|
|
_modelGarantiaInsUpdate.IdTipoCombustible = Model.Solicitud.Garantia.First().IdTipoCombustible;
|
|||
|
|
_modelGarantiaInsUpdate.Capacidad = Model.Solicitud.Garantia.First().Capacidad;
|
|||
|
|
_modelGarantiaInsUpdate.InscritoANombre = Model.Solicitud.Garantia.First().InscritoANombre;
|
|||
|
|
_modelGarantiaInsUpdate.IdCategoriaVehiculo = Model.Solicitud.Garantia.First().IdCategoriaVehiculo;
|
|||
|
|
_modelGarantiaInsUpdate.IdCarroceriaVehiculo = Model.Solicitud.Garantia.First().IdCarroceriaVehiculo;
|
|||
|
|
if (Model.Solicitud.Garantia.First().ConductorHabitual_IdTipoIdentificacion == 0)
|
|||
|
|
{
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_IdTipoIdentificacion = null;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Identificacion = null;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Nombre = null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_IdTipoIdentificacion = Model.Solicitud.Garantia.First().ConductorHabitual_IdTipoIdentificacion;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Identificacion = Model.Solicitud.Garantia.First().ConductorHabitual_Identificacion;
|
|||
|
|
_modelGarantiaInsUpdate.ConductorHabitual_Nombre = Model.Solicitud.Garantia.First().ConductorHabitual_Nombre;
|
|||
|
|
}
|
|||
|
|
_modelGarantiaInsUpdate.FechaVehSaleAgencia = Model.Solicitud.Garantia.First().FechaVehSaleAgencia;
|
|||
|
|
|
|||
|
|
db.Entry(_modelGarantiaInsUpdate).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
Cotizacion cot = db.Cotizacion.Where(q => q.IdCotizacion == Model.IdCotizacion).FirstOrDefault();
|
|||
|
|
if (cot != null)
|
|||
|
|
{
|
|||
|
|
cot.IngresoMinReqCol = Model.Solicitud.Cotizacion.IngresoMinReqCol;
|
|||
|
|
cot.IngresoMInReqDol = Model.Solicitud.Cotizacion.IngresoMInReqDol;
|
|||
|
|
cot.MontoComision = Model.Solicitud.Cotizacion.MontoComision;
|
|||
|
|
cot.MontoConstitucionPrenda = Model.Solicitud.Cotizacion.MontoConstitucionPrenda;
|
|||
|
|
cot.MontoPrestamo = Model.Solicitud.Cotizacion.MontoPrestamo;
|
|||
|
|
cot.MontoPrestamoSinSeguros = Model.Solicitud.Cotizacion.MontoPrestamoSinSeguros;
|
|||
|
|
cot.MontoDesembolso = Model.Solicitud.Cotizacion.MontoDesembolso;
|
|||
|
|
cot.MontoTraspaso = Model.Solicitud.Cotizacion.MontoTraspaso;
|
|||
|
|
cot.TipoCambio = Model.Solicitud.Cotizacion.TipoCambio;
|
|||
|
|
|
|||
|
|
db.Entry(cot).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);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
string message = ex.ToString();
|
|||
|
|
if (ex.InnerException != null)
|
|||
|
|
message += Environment.NewLine + ex.InnerException.ToString();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", message);
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void AgregarSegurosCotizacion(PrendarioContext db, int IdCotizacion, ICollection<SegurosCotizacion> SegurosCotizacion)
|
|||
|
|
{
|
|||
|
|
foreach (var s in SegurosCotizacion)
|
|||
|
|
{
|
|||
|
|
SegurosCotizacion _modelSeguro = new SegurosCotizacion();
|
|||
|
|
_modelSeguro.IdCotizacion = IdCotizacion;
|
|||
|
|
_modelSeguro.IdRubroSeguro = s.IdRubroSeguro;
|
|||
|
|
_modelSeguro.Monto = s.Monto;
|
|||
|
|
_modelSeguro.IdAgenteSeguro = s.IdAgenteSeguro;
|
|||
|
|
db.SegurosCotizacion.Add(_modelSeguro);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|