70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using System.Data.Entity;
|
|
using Ultimus.Interfaces;
|
|
|
|
namespace ULA.Cathay.CreditoModel.DAL.Credito
|
|
{
|
|
public class DatosGeneralesAnalisisDAL
|
|
{
|
|
UltimusLogs logs = new UltimusLogs("DatosGeneralesAnalisisDAL");
|
|
|
|
public DatosGeneralesAnalisis Obtener(int IdSolicitud)
|
|
{
|
|
DatosGeneralesAnalisis model = new DatosGeneralesAnalisis();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
model = db.DatosGeneralesAnalisis
|
|
.Include(c => c.Decision)
|
|
.Include(c => c.TipoSeguimiento)
|
|
.Where(c => c.IdSolicitud == IdSolicitud).FirstOrDefault();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
public BaseJson GuardarActualizarAnalisis(DatosGeneralesAnalisis model)
|
|
{
|
|
BaseJson respuesta = new BaseJson();
|
|
DatosGeneralesAnalisis actual = new DatosGeneralesAnalisis();
|
|
try
|
|
{
|
|
|
|
using (CreditoContex Conn = new CreditoContex())
|
|
{
|
|
model.ClearVirtualProperties();
|
|
actual = Conn.DatosGeneralesAnalisis.Where(x => x.IdSolicitud == model.IdSolicitud).FirstOrDefault();
|
|
if (actual == null)
|
|
{
|
|
Conn.DatosGeneralesAnalisis.Add(model);
|
|
}
|
|
else if (actual != null)
|
|
{
|
|
Conn.Entry(actual).State = System.Data.Entity.EntityState.Detached;
|
|
Conn.DatosGeneralesAnalisis.Attach(model);
|
|
Conn.Entry(model).State = System.Data.Entity.EntityState.Modified;
|
|
}
|
|
Conn.SaveChanges();
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
return respuesta;
|
|
}
|
|
}
|
|
}
|