149 lines
No EOL
5.7 KiB
C#
149 lines
No EOL
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Validation;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using System.Data.Entity;
|
|
using Ultimus.Utilitarios;
|
|
using Ultimus.Interfaces.UltimusForm;
|
|
using Ultimus.Interfaces;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using NLog;
|
|
using ULA.Cathay.ModuloMantenimiento.Json;
|
|
using ULA.Cathay.ModuloMantenimiento.Commons;
|
|
|
|
namespace ULA.Cathay.ModuloMantenimiento.ControllersWebApi
|
|
{
|
|
public class FormalizacionConfiguracionDocumentosLegalesAPIController : ApiController
|
|
{
|
|
private static Logger logger = LogManager.GetLogger("FormalizacionConfiguracionDocumentosLegalesAPIController");
|
|
|
|
private string _IDLogger;
|
|
public string IDLogger
|
|
{
|
|
get { return _IDLogger; }
|
|
set { _IDLogger = string.Format("INCIDENT {0}|", value); }
|
|
}
|
|
#region CategoriaPorFacilidad
|
|
|
|
|
|
#region Obtener
|
|
[HttpGet]
|
|
public List<FormalizacionConfiguracionDocumentosLegales> Obtener()
|
|
{
|
|
List<FormalizacionConfiguracionDocumentosLegales> respuesta = new List<FormalizacionConfiguracionDocumentosLegales>();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
respuesta = db.FormalizacionConfiguracionDocumentosLegales
|
|
.Include(x => x.Etapas)
|
|
.Include(x => x.TipoDocumento)
|
|
.Include(x=> x.VarianteConfiguracionDocumentosLegales)
|
|
.ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
}
|
|
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
#region toggleStateItem
|
|
[HttpPost]
|
|
public string toggleStateItem(FormalizacionConfiguracionDocumentosLegales model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
FormalizacionConfiguracionDocumentosLegales _model = db.FormalizacionConfiguracionDocumentosLegales.Where(t => t.IdConfiguracion == model.IdConfiguracion).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.Habilitado = model.Habilitado;
|
|
db.SaveChanges();
|
|
return TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region ModificarItem
|
|
[HttpPost]
|
|
public string ModificarItem(FormalizacionConfiguracionDocumentosLegales model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
FormalizacionConfiguracionDocumentosLegales _model = db.FormalizacionConfiguracionDocumentosLegales.Where(t => t.IdConfiguracion == model.IdConfiguracion).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.IdEtapa = model.IdEtapa;
|
|
_model.IdTipoDocumento = model.IdTipoDocumento;
|
|
_model.IdVariante = model.IdVariante;
|
|
_model.ValorVariante = model.ValorVariante;
|
|
_model.EsEspecifico = model.EsEspecifico;
|
|
db.SaveChanges();
|
|
return TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region InsertarItem
|
|
[HttpPost]
|
|
public string InsertarItem(FormalizacionConfiguracionDocumentosLegales model)
|
|
{
|
|
try
|
|
{
|
|
FormalizacionConfiguracionDocumentosLegales _model = new FormalizacionConfiguracionDocumentosLegales();
|
|
int? Next_id;
|
|
int idActual;
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
Next_id = db.Moneda.Max(t => (int?)t.IdMoneda);
|
|
idActual = (Next_id == null) ? 0 : Convert.ToInt32(Next_id);
|
|
_model.IdConfiguracion = (idActual + 1);
|
|
_model.IdEtapa = model.IdEtapa;
|
|
_model.IdTipoDocumento = model.IdTipoDocumento;
|
|
_model.IdVariante = model.IdVariante;
|
|
_model.ValorVariante = model.ValorVariante;
|
|
_model.EsEspecifico = model.EsEspecifico;
|
|
_model.Habilitado = true;
|
|
db.FormalizacionConfiguracionDocumentosLegales.Add(_model);
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
return TipoCodigoRespuesta.ERROR.ToString();
|
|
}
|
|
return TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
}
|
|
} |