using System; using System.Collections.Generic; using System.Configuration; using System.Data.Entity.Validation; using System.IO; using System.Linq; using System.Web; using System.Web.Http; using System.Text; using ULA.Davivienda.PrendarioModel.Prendario; using ULA.Davivienda.PrestamoAutos.Commons; using ULA.Davivienda.PrestamoAutos.Json; using ULA.Davivienda.PrestamoAutos.WCFAttachmentService; using ULA.Davivienda.PrestamoAutos.ServiciosCobisCarteraPrendario; using Ultimus.Utilitarios; namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi { public class LiquidacionAPIController: ApiController { LogFile log = new LogFile(); #region Enviar [HttpPost] public JsonResponseBase Enviar([FromBody] JsonEnviarLiquidacion _model) { JsonResponseBase respuesta = null; GlobalAPIController global = null; JsonLiquidarOperacionResponse resp = null; JsonResponseBase respRegSeguros = null; try { respuesta = new JsonResponseBase(); global = new GlobalAPIController(); if (_model.IdDecision == Convert.ToString((int)EnumDecision.IrAFin)) { //Invoca Seguros respRegSeguros = global.RegistrarSeguro(new JsonRegistrarTasaEscalonadaRequest() { IdSolicitud = (int)_model.IdSolicitud, ProcessName = _model.Process, UserId = _model.UserId.Split(new char[] { '/' })[1] }); if (respRegSeguros.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString()) { throw new Exception(respRegSeguros.DescripcionRespuesta); } //Invoca Liquidacion Completa resp = global.LiquidarOperacion(new JsonLiquidarOperacionRequest() { IdSolicitud = (int)_model.IdSolicitud, ProcessName = _model.Process, UserId = _model.UserId.Split(new char[] { '/' })[1] }); if (resp.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString()) { throw new Exception(resp.DescripcionRespuesta); } } respuesta = global.Enviar(_model); } catch (Exception ex) { log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex); respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString(); } finally { if (resp != null) respuesta.Alertas = resp.Alertas; } return respuesta; } #endregion } }