117 lines
3.8 KiB
C#
117 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using Ultimus.Interfaces;
|
|
using Ultimus.Utilitarios;
|
|
|
|
namespace ULA.Cathay.CreditoModel.DAL.Credito
|
|
{
|
|
|
|
public class CapacidadPagoDAL
|
|
{
|
|
private UltimusLogs logger = new UltimusLogs("CapacidadPagoDAL");
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<CapacidadPago> Obtener()
|
|
{
|
|
List<CapacidadPago> listaCapacidadPago = null;
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
listaCapacidadPago = db.CapacidadPago.ToList();
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
|
|
{
|
|
logger.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
}
|
|
return listaCapacidadPago;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public string Actualizar(CapacidadPago model)
|
|
{
|
|
string ValorRetorno = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
CapacidadPago _model = db.CapacidadPago.Where(t => t.IdCapacidadPago == model.IdCapacidadPago).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.UsuarioModificado = model.UsuarioModificado;
|
|
_model.FechaModificacion = DateTime.Now;
|
|
db.Entry(_model).State = System.Data.Entity.EntityState.Modified;
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
|
|
{
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
logger.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
logger.Error(ex);
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public string Insertar(CapacidadPago model)
|
|
{
|
|
string ValorRetorno = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
CapacidadPago _model = new CapacidadPago();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
{
|
|
_model.IdCapacidadPago = model.IdCapacidadPago;
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.Estado = true;
|
|
_model.UsuarioCreador = model.UsuarioCreador;
|
|
_model.FechaCreacion = DateTime.Now;
|
|
db.CapacidadPago.Add(_model);
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
|
|
{
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
logger.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
logger.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
_model = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
}
|
|
}
|