143 lines
No EOL
5.4 KiB
C#
143 lines
No EOL
5.4 KiB
C#
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using ULA.Cathay.ModuloMantenimiento.Commons;
|
|
using ULA.Cathay.ModuloMantenimiento.Json;
|
|
using Ultimus.Interfaces;
|
|
|
|
namespace ULA.Cathay.ModuloMantenimiento.ControllersWebApi
|
|
{
|
|
public class ClaseCIIUAPIController : ApiController
|
|
{
|
|
|
|
private static Logger logger = LogManager.GetLogger("ClaseCIIUAPIController");
|
|
|
|
private string _IDLogger;
|
|
public string IDLogger
|
|
{
|
|
get { return _IDLogger; }
|
|
set { _IDLogger = string.Format("INCIDENT {0}|", value); }
|
|
}
|
|
|
|
#region ClaseCIIU
|
|
|
|
#region ObtenerItems
|
|
[HttpGet]
|
|
public List<ClaseCIIU> ObtenerItems(string IDSeccionCIIU, string IDDivisionCIIU, string IDGrupoCIIU)
|
|
{
|
|
List<ClaseCIIU> listaClaseCIIU = null;
|
|
try
|
|
{
|
|
listaClaseCIIU = new List<ClaseCIIU>();
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
listaClaseCIIU = db.ClaseCIIU.Where(i => i.IdSeccionCIIU == IDSeccionCIIU && i.IdDivisionCIIU == IDDivisionCIIU && i.IdGrupoCIIU == IDGrupoCIIU ).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
}
|
|
return listaClaseCIIU;
|
|
}
|
|
#endregion
|
|
|
|
#region toggleStateItem
|
|
[HttpPost]
|
|
public string toggleStateItem(ClaseCIIU model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ClaseCIIU _model = db.ClaseCIIU.Where(t => t.IdClaseCIIU == model.IdClaseCIIU && t.IdGrupoCIIU == model.IdGrupoCIIU && t.IdDivisionCIIU == model.IdDivisionCIIU && t.IdSeccionCIIU == model.IdSeccionCIIU).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.Estado = model.Estado;
|
|
_model.UsuarioModificado = model.UsuarioModificado;
|
|
_model.FechaModificacion = DateTime.Now;
|
|
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(ClaseCIIU model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
ClaseCIIU _model = db.ClaseCIIU.Where(t => t.IdClaseCIIU == model.IdClaseCIIU && t.IdGrupoCIIU == model.IdGrupoCIIU && t.IdDivisionCIIU == model.IdDivisionCIIU && t.IdSeccionCIIU == model.IdSeccionCIIU).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.IdSeccionCIIU = model.IdSeccionCIIU;
|
|
_model.IdDivisionCIIU = model.IdDivisionCIIU;
|
|
_model.IdGrupoCIIU = model.IdGrupoCIIU;
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.UsuarioModificado = model.UsuarioModificado;
|
|
_model.FechaModificacion = DateTime.Now;
|
|
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(ClaseCIIU model)
|
|
{
|
|
try
|
|
{
|
|
ClaseCIIU _model = new ClaseCIIU();
|
|
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
|
|
_model.IdClaseCIIU = model.IdClaseCIIU;
|
|
_model.IdSeccionCIIU = model.IdSeccionCIIU;
|
|
_model.IdDivisionCIIU = model.IdDivisionCIIU;
|
|
_model.IdGrupoCIIU = model.IdGrupoCIIU;
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.Estado = true;
|
|
_model.UsuarioCreador = model.UsuarioCreador;
|
|
_model.FechaCreacion = DateTime.Now;
|
|
db.ClaseCIIU.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
|
|
|
|
}
|
|
} |