186 lines
8 KiB
C#
186 lines
8 KiB
C#
using System;
|
|
using System.Linq;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using Ultimus.Utilitarios;
|
|
using Ultimus.Interfaces;
|
|
using System.Data.Entity;
|
|
using System.Data.Entity.Validation;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace ULA.Cathay.CreditoModel.DAL.Credito
|
|
{
|
|
public class DatosGeneralesSeguimientoDAL
|
|
{
|
|
UltimusLogs logs = new UltimusLogs("DatosGeneralesSeguimientoDAL");
|
|
|
|
|
|
public DatosGeneralesSeguimiento Obtener(int? IdSolicitud, int? Secuencia, int? IdProceso, int? Incident, int? IdTipoSeguimiento)
|
|
{
|
|
DatosGeneralesSeguimiento ObjDatosGeneralesSeguimiento = new DatosGeneralesSeguimiento();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex Conn = new CreditoContex())
|
|
{
|
|
ObjDatosGeneralesSeguimiento = Conn.DatosGeneralesSeguimiento
|
|
.Where(q => (IdSolicitud == null || q.IdSolicitud == IdSolicitud)
|
|
&& (Secuencia == null || q.Secuencia == Secuencia)
|
|
&& (IdProceso == null || q.IdProceso == IdProceso)
|
|
&& (Incident == null || q.Incident == Incident)
|
|
&& (IdTipoSeguimiento == null || q.IdTipoSeguimiento == IdTipoSeguimiento))
|
|
.Include(e => e.Solicitud)
|
|
.Include(e => e.Procesos)
|
|
.FirstOrDefault();
|
|
|
|
}
|
|
|
|
}
|
|
catch (DbEntityValidationException ex1)
|
|
{
|
|
logs.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
}
|
|
|
|
return ObjDatosGeneralesSeguimiento;
|
|
}
|
|
|
|
public List<DatosGeneralesSeguimiento> ObtenerLista(int? IdSolicitud, int? Secuencia, int? IdProceso, int? Incident, int? IdTipoSeguimiento)
|
|
{
|
|
List<DatosGeneralesSeguimiento> ObjDatosGeneralesSeguimiento = new List<DatosGeneralesSeguimiento>();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex Conn = new CreditoContex())
|
|
{
|
|
ObjDatosGeneralesSeguimiento = Conn.DatosGeneralesSeguimiento
|
|
.Where(q => (IdSolicitud == null || q.IdSolicitud == IdSolicitud)
|
|
&& (Secuencia == null || q.Secuencia == Secuencia)
|
|
&& (IdProceso == null || q.IdProceso == IdProceso)
|
|
&& (Incident == null || q.Incident == Incident)
|
|
&& (IdTipoSeguimiento == null || q.IdTipoSeguimiento == IdTipoSeguimiento))
|
|
.Include(e => e.Solicitud)
|
|
.Include(e => e.Procesos)
|
|
.ToList();
|
|
|
|
}
|
|
|
|
}
|
|
catch (DbEntityValidationException ex1)
|
|
{
|
|
logs.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
finally
|
|
{
|
|
}
|
|
|
|
return ObjDatosGeneralesSeguimiento;
|
|
}
|
|
|
|
public BaseJson InsertarActualizar(DatosGeneralesSeguimiento modelo)
|
|
{
|
|
DatosGeneralesSeguimiento ModeloActual = new DatosGeneralesSeguimiento();
|
|
BaseJson ValorRetorno = new BaseJson();
|
|
|
|
CaratulaCreditoExcepcionesPoliticaBitacoraDAL CCExcepcionesPoliticaBitacoraDal = new CaratulaCreditoExcepcionesPoliticaBitacoraDAL();
|
|
CaratulaCreditoCondicionesEspecialesBitacoraDAL CCCondicionesEspecialesBitacoraDal = new CaratulaCreditoCondicionesEspecialesBitacoraDAL();
|
|
|
|
ICollection<CaratulaCreditoExcepcionesPoliticaBitacora> ListaCaratulaCreditoExcepcionesPoliticaBitacora = null;
|
|
ICollection<CaratulaCreditoCondicionesEspecialesBitacora> ListaCaratulaCreditoCondicionesEspecialesBitacora = null;
|
|
|
|
try
|
|
{
|
|
ValorRetorno.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
ListaCaratulaCreditoExcepcionesPoliticaBitacora = modelo.CaratulaCreditoExcepcionesPoliticaBitacora;
|
|
ListaCaratulaCreditoCondicionesEspecialesBitacora = modelo.CaratulaCreditoCondicionesEspecialesBitacora;
|
|
|
|
modelo.Procesos = null;
|
|
modelo.Solicitud = null;
|
|
modelo.CaratulaCreditoExcepcionesPoliticaBitacora = null;
|
|
modelo.CaratulaCreditoCondicionesEspecialesBitacora = null;
|
|
|
|
|
|
using (CreditoContex Conn = new CreditoContex())
|
|
{
|
|
ModeloActual = (Conn.DatosGeneralesSeguimiento
|
|
.Where(q => q.IdSolicitud == modelo.IdSolicitud
|
|
&& q.Secuencia == modelo.Secuencia
|
|
&& q.IdProceso == modelo.IdProceso
|
|
&& q.Incident == modelo.Incident
|
|
&& q.IdTipoSeguimiento == modelo.IdTipoSeguimiento)).FirstOrDefault();
|
|
if (ModeloActual == null)
|
|
{
|
|
modelo.FechaCreacion = DateTime.Now;
|
|
Conn.DatosGeneralesSeguimiento.Add(modelo);
|
|
}
|
|
else
|
|
{
|
|
modelo.FechaModificacion = DateTime.Now;
|
|
modelo.UsuarioModificado = modelo.UsuarioCreador;
|
|
modelo.FechaCreacion = ModeloActual.FechaCreacion;
|
|
modelo.UsuarioCreador = ModeloActual.UsuarioCreador;
|
|
|
|
Conn.Entry(ModeloActual).State = System.Data.Entity.EntityState.Detached;
|
|
Conn.DatosGeneralesSeguimiento.Attach(modelo);
|
|
Conn.Entry(modelo).State = System.Data.Entity.EntityState.Modified;
|
|
}
|
|
Conn.SaveChanges();
|
|
}
|
|
|
|
|
|
if (ListaCaratulaCreditoExcepcionesPoliticaBitacora != null)
|
|
{
|
|
foreach (var ItemCaratulaCreditoExcepcionesPoliticaBitacora in ListaCaratulaCreditoExcepcionesPoliticaBitacora)
|
|
{
|
|
var resp = CCExcepcionesPoliticaBitacoraDal.InsertarActualizar(ItemCaratulaCreditoExcepcionesPoliticaBitacora);
|
|
if (resp.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|
throw new Exception(resp.DescripcionRespuesta);
|
|
}
|
|
}
|
|
|
|
|
|
if (ListaCaratulaCreditoCondicionesEspecialesBitacora != null)
|
|
{
|
|
foreach (var ItemCaratulaCreditoCondicionesEspecialesBitacora in ListaCaratulaCreditoCondicionesEspecialesBitacora)
|
|
{
|
|
var resp = CCCondicionesEspecialesBitacoraDal.InsertarActualizar(ItemCaratulaCreditoCondicionesEspecialesBitacora);
|
|
if (resp.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|
throw new Exception(resp.DescripcionRespuesta);
|
|
}
|
|
}
|
|
}
|
|
catch (DbEntityValidationException ex1)
|
|
{
|
|
ValorRetorno.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
logs.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ValorRetorno.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
ModeloActual = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|