TFS_ANTIGUO/SInCathay/ULA.Cathay.CreditoModel.DAL/Credito/GestionRenovacionLineasDAL.cs

63 lines
1.9 KiB
C#

using System;
using System.Linq;
using ULA.Cathay.CreditoModel.Credito;
using Ultimus.Utilitarios;
using System.Data.Entity;
namespace ULA.Cathay.CreditoModel.DAL.Credito
{
public class GestionRenovacionLineasDAL
{
private UltimusLogs logs = new UltimusLogs("GestionRenovacionLineasDAL");
public GestionRenovacionLineas Obtener(int IdSolicitud)
{
GestionRenovacionLineas model = new GestionRenovacionLineas();
try
{
using (CreditoContex db = new CreditoContex())
model = db.GestionRenovacionLineas.Where(c => c.IdSolicitud == IdSolicitud)
.Include(c => c.Moneda)
.Include("Solicitud.Solicitante.Cliente.Ejecutivo")
.Include("Solicitud.Solicitante.Cliente.BitacoraDocumentosCliente.TipoDocumento.TipoExpedienteDocumentos")
.Include("Solicitud.Solicitante.Cliente.BitacoraDocumentosCliente.TipoDocumento.TipoDocumentoEpower")
.AsNoTracking()
.FirstOrDefault();
}
catch (Exception ex)
{
logs.Error(ex);
}
return model;
}
public GestionRenovacionLineas InsertarActualizar(GestionRenovacionLineas model)
{
try
{
using (CreditoContex db = new CreditoContex())
{
if (db.GestionRenovacionLineas.AsNoTracking().Where(c => c.IdSolicitud == model.IdSolicitud).Any())
db.Entry(model).State = System.Data.Entity.EntityState.Modified;
else
db.GestionRenovacionLineas.Add(model);
db.SaveChanges();
}
}
catch (Exception ex)
{
logs.Error(ex);
}
return model;
}
}
}