Esempio n. 1
0
        public IHttpActionResult GetBuscarCodigo(bool conStock, string codigo, int cliente)
        {
            try
            {
                ServiciosProductos servicio     = new ServiciosProductos();
                ProductoList       productoList = null;

                productoList = servicio.ProductoListarCarrito(conStock, -1, codigo, cliente, -1, -1);

                Producto resp = productoList.Productos.Find(item => item.Codigo.Equals(codigo.ConvertirInt()));

                LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp));

                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.GetExceptionOriginal().Message));
            }
        }
Esempio n. 2
0
        public IHttpActionResult GetListarBusqueda(bool conStock, int subcategoria, string textoBuscar, int cliente, int numeroPagina, int cantidadRegistros)
        {
            try
            {
                ServiciosProductos servicio               = new ServiciosProductos();
                ServicioGenerico   servGenerico           = new ServicioGenerico();
                string             estamosEnMantenimiento = servGenerico.ParametroObtenerValor("HOST_EN_MANTENIMIENTO");

                ProductoList resp = null;

                if (estamosEnMantenimiento.Equals("SI"))
                {
                    resp = servicio.ProductoListarEstamosEnMantenimiento();
                }
                else
                {
                    resp = servicio.ProductoListarCarrito(conStock, subcategoria, textoBuscar, cliente, numeroPagina, cantidadRegistros);
                }

                //LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp));

                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.GetExceptionOriginal().Message));
            }
        }
        public IHttpActionResult GetAll(int idListaPrecio)
        {
            try
            {
                ServiciosProductos        servicio = new ServiciosProductos();
                List <ListaPrecioCliente> resp     = null;
                List <ListaPrecioCliente> lista    = servicio.Listar <ListaPrecioCliente>();

                if (lista != null)
                {
                    resp = lista.Where(item => item.ListaPrecio.Id.Equals(idListaPrecio))
                           .OrderBy(item => item.Codigo)
                           .ToList <ListaPrecioCliente>();
                }

                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 4
0
        public HttpResponseMessage ExportarEtiquetas(int idSubcategoria, int tipoListado)
        {
            HttpResponseMessage result = null;

            try
            {
                ServiciosProductos  servicio      = new ServiciosProductos();
                ProcesadorPlantilla procPlantilla = new ProcesadorPlantilla("ListadoProductos");

                procPlantilla.DiccionarioDatos = servicio.ExportarListadoProductos(idSubcategoria, tipoListado);
                procPlantilla.ProcesarPlantilla();

                //// Exportacion a Excel
                byte[]       byteArray    = Encoding.UTF8.GetBytes(procPlantilla.HTMLProcesado);
                MemoryStream reportStream = new MemoryStream(byteArray);

                result = Request.CreateResponse(HttpStatusCode.OK);

                result.Content = new StreamContent(reportStream);
                result.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = string.Format("Productos_{0}_{1}.xls", idSubcategoria.ToString(), DateTime.Now.ToString("yyyyMMdd"))
                };

                return(result);

                /*
                 * * * exportar a PDF
                 * List<string> contenidoHTML = new List<string>();
                 * ProcesadorPDF procesador = new ProcesadorPDF();
                 * Document _docPDF = null;
                 *
                 * contenidoHTML.Add(procPlantilla.HTMLProcesado);
                 *
                 * procesador.MostrarEncabezado = true;
                 * procesador.AltoEncabezado = 30;
                 * procesador.MostrarPieDePagina = true;
                 * procesador.AltoPieDePagina = 20;
                 * procesador.TextoPieDePagina = true;
                 *
                 * _docPDF = procesador.ProcesarDocumentoPDF(contenidoHTML);
                 * byte[] outPdfBuffer = _docPDF.Save();
                 *
                 * result = Request.CreateResponse(HttpStatusCode.OK);
                 * result.Content = new ByteArrayContent(outPdfBuffer);
                 * result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
                 * result.Content.Headers.ContentDisposition.FileName = string.Format("Productos_{0}_{1}.pdf", idSubcategoria.ToString(), DateTime.Now.ToString("yyyyMMdd"));
                 *
                 * return result;
                 */
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(Request.CreateResponse(HttpStatusCode.Gone));
            }
        }
 // POST api/listapreciocliente
 public IHttpActionResult Post([FromBody] ListaPrecioCliente datos)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         ListaPrecioCliente resp     = servicio.ListaPrecioClienteGrabar(datos);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 6
0
 public IHttpActionResult GetBuscar(string buscar, bool soloCodigo, int numeroPagina, int cantidadRegistros)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         ProductoList       resp     = servicio.ProductoBusqueda(buscar, soloCodigo, false, numeroPagina, cantidadRegistros);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(string.Format("ex.Message=>\n{0}\n\nex.InnerException=>\n{1}\n\nex.StackTrace=>\n{2}", ex.Message, (ex.InnerException != null ? ex.InnerException.Message : string.Empty), ex.StackTrace)));
     }
 }
 // GET api/listapreciocliente/5
 public IHttpActionResult Get(int id)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         ListaPrecioCliente resp     = servicio.ObtenerObjeto <ListaPrecioCliente>(id);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
 // GET api/listapreciocliente
 public IHttpActionResult Get()
 {
     try
     {
         ServiciosProductos        servicio = new ServiciosProductos();
         List <ListaPrecioCliente> resp     = servicio.ListarVigentes <ListaPrecioCliente>();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 9
0
 // POST api/parametro
 public IHttpActionResult Post([FromBody] CotizacionDolar datos)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         CotizacionDolar    resp     = servicio.CotizacionDolarGrabar(datos);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 10
0
 public IHttpActionResult PostEliminar(int id)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         CotizacionDolar    resp     = servicio.CotizacionDolarEliminar(id);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 11
0
 // GET api/parametro/5
 public IHttpActionResult Get(int id)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         CotizacionDolar    resp     = servicio.CotizacionDolarObtenerCache()
                                       .FirstOrDefault(item => item.Id.Equals(id));
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 12
0
 public IHttpActionResult GetListarABM(int subcategoria, int tipoListado, int numeroPagina, int cantidadRegistros)
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         ProductoList       resp     = servicio.ProductoListarABM(subcategoria, tipoListado, numeroPagina, cantidadRegistros);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Esempio n. 13
0
 // GET api/tipo
 public IHttpActionResult Get()
 {
     try
     {
         ServiciosProductos     servicio = new ServiciosProductos();
         List <CotizacionDolar> resp     = servicio.Listar <CotizacionDolar>()
                                           .OrderByDescending(item => item.Fecha)
                                           .ToList <CotizacionDolar>();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 14
0
 // GET api/producto
 public IHttpActionResult Get()
 {
     try
     {
         /// no se deberia llamar de ningun lado que liste todos los productos de una
         ServiciosProductos servicio = new ServiciosProductos();
         List <Producto>    resp     = new List <Producto>();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
         return(BadRequest(ex.GetExceptionOriginal().Message));
     }
 }
Esempio n. 15
0
        // GET api/producto/5
        public IHttpActionResult Get(int id)
        {
            try
            {
                ServiciosProductos servicio = new ServiciosProductos();
                Producto           resp     = servicio.ObtenerObjeto <Producto>(id);

                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 16
0
 public IHttpActionResult GetVigentes()
 {
     try
     {
         ServiciosProductos servicio = new ServiciosProductos();
         List <ListaPrecio> resp     = servicio.ListarVigentes <ListaPrecio>()
                                       .OrderBy(item => item.Codigo)
                                       .ToList <ListaPrecio>();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Esempio n. 17
0
 // POST api/producto
 public IHttpActionResult Post([FromBody] Producto datos)
 {
     try
     {
         ServiciosProductos servicio  = new ServiciosProductos();
         string             pathFotos = HttpContext.Current.Server.MapPath(string.Format("{0}", this.DamePathFoto()));
         Producto           resp      = servicio.ProductoGrabar(datos, pathFotos);
         if (resp == null)
         {
             return(NotFound());
         }
         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 producto no se pudo actualizar."));
     }
 }