97 lines
2.7 KiB
C#
97 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using System.Data.Entity;
|
|
using System.Data.Entity.Validation;
|
|
|
|
namespace ULA.Cathay.CreditoModel.DAL.Credito
|
|
{
|
|
public class ClasificacionDocumentosAdjuntosDAL
|
|
{
|
|
UltimusLogs logs = new UltimusLogs("ClasificacionDocumentosAdjuntosDAL");
|
|
|
|
|
|
public ClasificacionDocumentosAdjuntos InsertarActualizar(ClasificacionDocumentosAdjuntos model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
|
|
var exist = db.ClasificacionDocumentosAdjuntos.AsNoTracking().Any(c => c.CodDocumento == model.CodDocumento);
|
|
|
|
model.ClearVirtualProperties();
|
|
|
|
if (!exist)
|
|
{
|
|
db.Set(model.GetType()).Add(model);
|
|
}
|
|
else
|
|
{
|
|
db.Set(model.GetType()).Attach(model);
|
|
db.Entry(model).State = EntityState.Modified;
|
|
}
|
|
db.SaveChanges();
|
|
|
|
}
|
|
}
|
|
catch (DbEntityValidationException ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
public List<ClasificacionDocumentosAdjuntos> ObtenerDocumentos(int IdCliente)
|
|
{
|
|
List<ClasificacionDocumentosAdjuntos> model = new List<ClasificacionDocumentosAdjuntos>();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
model = db.ClasificacionDocumentosAdjuntos.Where(c => c.IdCliente == IdCliente).ToList();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
public ClasificacionDocumentosAdjuntos Obtener(long CodDocumento)
|
|
{
|
|
ClasificacionDocumentosAdjuntos model = new ClasificacionDocumentosAdjuntos();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
model = db.ClasificacionDocumentosAdjuntos.Where(c => c.CodDocumento == CodDocumento).FirstOrDefault();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
throw ex;
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
}
|
|
}
|