139 lines
No EOL
4.9 KiB
C#
139 lines
No EOL
4.9 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 DivisionCIIUAPIController : ApiController
|
|
{
|
|
|
|
private static Logger logger = LogManager.GetLogger("DivisionCIIUAPIController");
|
|
|
|
private string _IDLogger;
|
|
public string IDLogger
|
|
{
|
|
get { return _IDLogger; }
|
|
set { _IDLogger = string.Format("INCIDENT {0}|", value); }
|
|
}
|
|
|
|
#region DivisionCIIU
|
|
|
|
#region ObtenerItems
|
|
[HttpGet]
|
|
public List<DivisionCIIU> ObtenerItems(string IDSeccionCIIU)
|
|
{
|
|
List<DivisionCIIU> listaDivisionCIIU = null;
|
|
try
|
|
{
|
|
listaDivisionCIIU = new List<DivisionCIIU>();
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
listaDivisionCIIU = db.DivisionCIIU.Where(i => i.IdSeccionCIIU == IDSeccionCIIU).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|
}
|
|
return listaDivisionCIIU;
|
|
}
|
|
#endregion
|
|
|
|
#region toggleStateItem
|
|
[HttpPost]
|
|
public string toggleStateItem(DivisionCIIU model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
DivisionCIIU _model = db.DivisionCIIU.Where(t => 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(DivisionCIIU model)
|
|
{
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
DivisionCIIU _model = db.DivisionCIIU.Where(t => t.IdDivisionCIIU == model.IdDivisionCIIU && t.IdSeccionCIIU == model.IdSeccionCIIU).FirstOrDefault();
|
|
if (_model != null)
|
|
{
|
|
_model.IdSeccionCIIU = model.IdSeccionCIIU;
|
|
_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(DivisionCIIU model)
|
|
{
|
|
try
|
|
{
|
|
DivisionCIIU _model = new DivisionCIIU();
|
|
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
|
|
_model.IdDivisionCIIU = model.IdDivisionCIIU;
|
|
_model.IdSeccionCIIU = model.IdSeccionCIIU;
|
|
_model.Descripcion = model.Descripcion;
|
|
_model.Estado = true;
|
|
_model.UsuarioCreador = model.UsuarioCreador;
|
|
_model.FechaCreacion = DateTime.Now;
|
|
db.DivisionCIIU.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
|
|
|
|
}
|
|
} |