160 lines
6.1 KiB
C#
160 lines
6.1 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 MatrizOfertaAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
private static Logger logger = LogManager.GetLogger("MatrizOfertaAPIController");
|
|||
|
|
|
|||
|
|
private string _IDLogger;
|
|||
|
|
public string IDLogger
|
|||
|
|
{
|
|||
|
|
get { return _IDLogger; }
|
|||
|
|
set { _IDLogger = string.Format("INCIDENT {0}|", value); }
|
|||
|
|
}
|
|||
|
|
#region MatrizOferta
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ObtenerMatrizOferta
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonMatrizOferta> ObtenerItems()
|
|||
|
|
{
|
|||
|
|
List<JsonMatrizOferta> respuesta = new List<JsonMatrizOferta>();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (CreditoContex db = new CreditoContex())
|
|||
|
|
{
|
|||
|
|
respuesta = (from d in db.MatrizOferta
|
|||
|
|
.Include(x => x.TipoSeleccion)
|
|||
|
|
.Include(x => x.CriterioSeleccion)
|
|||
|
|
.Include(x => x.TipoFacilidad)
|
|||
|
|
select new JsonMatrizOferta
|
|||
|
|
{
|
|||
|
|
IdTipoFacilidad = d.IdTipoFacilidad,
|
|||
|
|
DescripcionFacilidad = d.TipoFacilidad.Descripcion,
|
|||
|
|
IdTipoSeleccion = d.IdTipoSeleccion,
|
|||
|
|
DescripcionSeleccion = d.TipoSeleccion.Descripcion,
|
|||
|
|
IdCriterioSeleccion = d.IdCriterioSeleccion,
|
|||
|
|
DescripcionCriterio = d.CriterioSeleccion.Descripcion,
|
|||
|
|
Porcentaje = d.Porcentaje,
|
|||
|
|
Estado = d.Estado
|
|||
|
|
}).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
logger.Error(IDLogger + " Error " + Utilities.GetCurrentMethodName() + "=" + ex.Message + ex.StackTrace);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region toggleStateItem
|
|||
|
|
[HttpPost]
|
|||
|
|
public string toggleStateItem(MatrizOferta model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (CreditoContex db = new CreditoContex())
|
|||
|
|
{
|
|||
|
|
MatrizOferta _model = db.MatrizOferta.Where(t => t.IdTipoSeleccion == model.IdTipoSeleccion && t.IdTipoFacilidad == model.IdTipoFacilidad).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(MatrizOferta model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (CreditoContex db = new CreditoContex())
|
|||
|
|
{
|
|||
|
|
MatrizOferta _model = db.MatrizOferta.Where(t => t.IdTipoSeleccion == model.IdTipoSeleccion && t.IdTipoFacilidad == model.IdTipoFacilidad).FirstOrDefault();
|
|||
|
|
if (_model != null)
|
|||
|
|
{
|
|||
|
|
_model.IdTipoFacilidad = model.IdTipoFacilidad;
|
|||
|
|
_model.IdTipoSeleccion = model.IdTipoSeleccion;
|
|||
|
|
_model.IdCriterioSeleccion = model.IdCriterioSeleccion;
|
|||
|
|
_model.Porcentaje = model.Porcentaje;
|
|||
|
|
_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(MatrizOferta model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
MatrizOferta _model = new MatrizOferta();
|
|||
|
|
using (CreditoContex db = new CreditoContex())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
_model.IdTipoFacilidad = model.IdTipoFacilidad;
|
|||
|
|
_model.IdTipoSeleccion = model.IdTipoSeleccion;
|
|||
|
|
_model.IdCriterioSeleccion = model.IdCriterioSeleccion;
|
|||
|
|
_model.Porcentaje = model.Porcentaje;
|
|||
|
|
_model.Estado = true;
|
|||
|
|
_model.UsuarioCreador = model.UsuarioCreador;
|
|||
|
|
_model.FechaCreacion = DateTime.Now;
|
|||
|
|
db.MatrizOferta.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
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|