124 lines
4 KiB
C#
124 lines
4 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 ConsultaCICDAL
|
|
{
|
|
private UltimusLogs logger = new UltimusLogs("ConsultaCICDAL");
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ConsultaCIC> Obtener()
|
|
{
|
|
List<ConsultaCIC> listaConsultaCIC = new List<ConsultaCIC>();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
listaConsultaCIC = db.ConsultaCIC.ToList();
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
|
|
{
|
|
logger.Error(ex1);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
}
|
|
return listaConsultaCIC;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public string Actualizar(ConsultaCIC model)
|
|
{
|
|
ConsultaCIC _model = new ConsultaCIC();
|
|
string ValorRetorno = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
_model = db.ConsultaCIC.Where(t => t.IdConsultaCIC == model.IdConsultaCIC).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)
|
|
{
|
|
logger.Error(ex1);
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
finally
|
|
{
|
|
_model = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public string InsertarItem(ConsultaCIC model)
|
|
{
|
|
ConsultaCIC _model = new ConsultaCIC();
|
|
string ValorRetorno = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
int? Next_id;
|
|
int idActual;
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
Next_id = db.ConsultaCIC.Max(t => (int?)t.IdConsultaCIC);
|
|
idActual = (Next_id == null) ? 0 : Convert.ToInt32(Next_id);
|
|
_model.IdConsultaCIC = (idActual + 1);
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.Estado = true;
|
|
_model.UsuarioCreador = model.UsuarioCreador;
|
|
_model.FechaCreacion = DateTime.Now;
|
|
db.ConsultaCIC.Add(_model);
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException ex1)
|
|
{
|
|
logger.Error(ex1);
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(ex);
|
|
ValorRetorno = TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
finally
|
|
{
|
|
_model = null;
|
|
}
|
|
return ValorRetorno;
|
|
}
|
|
}
|
|
}
|