public IHttpActionResult Avanzar([FromBody] Pedido datos) { try { ServiciosPedido servicio = new ServiciosPedido(); MensajeResponse resp = servicio.PedidoAvanzar(datos, false); if (resp == null) { return(NotFound()); } LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp)); return(Ok(resp)); } catch (ApplicationException ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar.")); } }
public IHttpActionResult PedidoItemMinorista(int idPedido, int codigo, int cantidad) { try { ServiciosPedido servicio = new ServiciosPedido(); LoggerHelper.LogInfo(MethodBase.GetCurrentMethod(), string.Format("idPedido={0} - codigo={1} - cantidad={2}", idPedido, codigo, cantidad)); PedidoItem datos = new PedidoItem(); datos.IdPedido = idPedido; datos.Producto = servicio.ObtenerObjeto <Producto>("Codigo", codigo); datos.Cantidad = cantidad; Pedido resp = servicio.PedidoItemGrabar(datos); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar." + ex.Message)); } }
public IHttpActionResult Crear(int idCliente) { try { ServiciosPedido servicio = new ServiciosPedido(); Pedido resp = servicio.PedidoCrear(idCliente); if (resp == null) { return(NotFound()); } LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp)); return(Ok(resp)); } catch (ApplicationException ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar.")); } }
// POST api/pedido public IHttpActionResult Post([FromBody] PedidoItem datos) { try { ServiciosPedido servicio = new ServiciosPedido(); LoggerHelper.LogInfo(MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(datos)); Pedido resp = servicio.PedidoItemGrabar(datos); if (resp.Items == null || resp.Items.Count == 0) { resp.Items = servicio.PedidoObtenerItems(resp.Id, -1, -1); } if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar." + ex.Message)); } }
public IHttpActionResult PostEliminar(int id) { try { ServiciosPedido servicio = new ServiciosPedido(); servicio.PedidoItemEliminar(id); return(Ok("OK")); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo eliminar.")); } }
public IHttpActionResult Obtener(int idPedido, int numeroPagina, int cantidadRegistros) { try { ServiciosPedido servicio = new ServiciosPedido(); Pedido resp = servicio.PedidoObtener(idPedido, numeroPagina, cantidadRegistros); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
// GET api/Pedido public IHttpActionResult Get() { try { ServiciosPedido servicio = new ServiciosPedido(); List <Pedido> resp = servicio.Listar <Pedido>().ToList <Pedido>(); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
// POST api/pedido public IHttpActionResult Post([FromBody] Pedido datos) { try { ServiciosPedido servicio = new ServiciosPedido(); Pedido resp = servicio.PedidoGrabar(datos); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
// GET api/pedidoitem/5 public IHttpActionResult Get(int id) { try { ServiciosPedido servicio = new ServiciosPedido(); PedidoItem resp = servicio.ObtenerObjeto <PedidoItem>(id); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
public IHttpActionResult ListPaginado(string estados, int idCliente, string fechaDesde, string fechaHasta, int numeroPagina, int cantidadRegistros) { try { ServiciosPedido servicio = new ServiciosPedido(); PedidoList resp = servicio.PedidoListar(estados, idCliente, fechaDesde, fechaHasta, numeroPagina, cantidadRegistros); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
public IHttpActionResult Cliente(int idCliente, int numeroPagina, int cantidadRegistros) { try { LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), string.Format("PedidoObtenerClienteIngresado idCliente: {0} ", idCliente)); ServiciosPedido servicio = new ServiciosPedido(); Pedido resp = servicio.PedidoObtenerClienteIngresado(idCliente, numeroPagina, cantidadRegistros); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } }
public IHttpActionResult PostCambioEstado([FromBody] PedidoItem datos) { try { ServiciosPedido servicio = new ServiciosPedido(); PedidoItem resp = servicio.PedidoItemGrabarCambioEstado(datos); if (resp == null) { return(NotFound()); } return(Ok(resp)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar.")); } }
public IHttpActionResult Cancelar(int idPedido) { try { ServiciosPedido servicio = new ServiciosPedido(); servicio.PedidoCancelar(idPedido); return(Ok()); } catch (ApplicationException ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar.")); } }
public HttpResponseMessage ExportarEtiquetas(int idPedido) { HttpResponseMessage result = null; try { ServiciosPedido servicio = new ServiciosPedido(); //ProcesadorPlantilla procPlantilla = new ProcesadorPlantilla("ListadoEtiquetas"); //procPlantilla.DiccionarioDatos = servicio.ImprimirEtiquetas(idPedido); //procPlantilla.ProcesarPlantilla(); //// Exportacion a Excel string registros = servicio.ImprimirEtiquetas(idPedido); byte[] byteArray = Encoding.UTF8.GetBytes(registros); MemoryStream reportStream = new MemoryStream(byteArray); result = Request.CreateResponse(HttpStatusCode.OK); result.Content = new StreamContent(reportStream); //excel //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); //csv result.Content.Headers.ContentType = new MediaTypeHeaderValue("text/csv"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = string.Format("Pedido_{0}_{1}.csv", idPedido.ToString(), DateTime.Now.ToString("yyyyMMdd")) }; return(result); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(Request.CreateResponse(HttpStatusCode.Gone)); } }
public IHttpActionResult PedidoMinorista([FromBody] PedidoDTO datos) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), "Entró en GET => PedidoMinorista(string datos)"); try { ServiciosPedido servicio = new ServiciosPedido(); LoggerHelper.LogError(MethodBase.GetCurrentMethod(), string.Format("datos \n{0}", JsonConvert.SerializeObject(datos))); if (datos == null) { throw new ApplicationException("Llegó parametro en null la puta que te parió!!"); } //PedidoDTO datosDTO = JsonConvert.DeserializeObject<PedidoDTO>(datos); //LoggerHelper.LogError(MethodBase.GetCurrentMethod(), string.Format("PedidoDTO datosDTO \n{0}", JsonConvert.SerializeObject(datosDTO))); //Pedido resp = servicio.PedidoProcesarMinorista(datosDTO); Pedido resp = servicio.PedidoProcesarMinorista(datos); LoggerHelper.LogError(System.Reflection.MethodBase.GetCurrentMethod(), string.Format("Pedido generado\n{0}\n\n", JsonConvert.SerializeObject(resp))); return(Ok(resp)); } catch (ApplicationException ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest(ex.Message)); } catch (Exception ex) { LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex); return(BadRequest("El pedido no se pudo actualizar.")); } }