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