Exemple #1
0
        private void QryPorNombreCategoriaAproximada()
        {
            Console.WriteLine("Consulta de producto por nombre de la categoria aproximada.");
            Console.WriteLine("--------------------");
            Console.WriteLine("Digite el nombre de la categoria: ");
            var x = ObtenerHilera();

            if (x != null)
            {
                var elServicio  = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
                var elResultado = elServicio.QryPorNombreCategoriaAproximado(x);
                if (elResultado != null && elResultado.Count > 0)
                {
                    ImprimirListaDeProductos(elResultado);
                }
                else
                {
                    Console.WriteLine($"No se encontró el producto con nombre de proveedor {x}. Por favor revise.");
                }
            }
            else
            {
                Console.WriteLine("Ocurrió un error al obtener el nombre del proveedor. Por favor revise.");
            }
        }
Exemple #2
0
        private void QryPorId()
        {
            Console.WriteLine("Consulta de producto por Id.");
            Console.WriteLine("--------------------");
            Console.WriteLine("Digite el código de producto: ");
            var x = ObtenerNumero();

            if (x != null)
            {
                int a = 0;
                try
                {
                    a = (int)x;
                    var elServicio  = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
                    var elResultado = elServicio.QryPorId(a);
                    if (elResultado != null)
                    {
                        ImprimirProducto(elResultado);
                    }
                    else
                    {
                        Console.WriteLine($"No se encontró el producto con id {a}. Por favor revise.");
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Ocurrió un error al convertir los argumentos a números. Por favor revise.");
                }
            }
            else
            {
                Console.WriteLine("Ocurrió un error al convertir los argumentos a números. Por favor revise.");
            }
        }
        public IActionResult Get()
        {
            var elServicio          = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
            var elResultadoRecibido = elServicio.QryAllProducts();
            var elResultadoDevuelto = _mapper.Map <IList <Topicos.NorthWnd.Model.Models.Product>, IList <Products.API.ViewModels.ProductQry> >(elResultadoRecibido);

            return(Ok(elResultadoDevuelto));
            //elResultado);
        }
        public IActionResult CreateProduct([FromBody] ProductInsert elProducto)
        {
            var elServicio             = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
            var elProductoParaInsertar = _mapper.Map <Topicos.NorthWnd.Model.Models.Product>(elProducto);
            var elIdRecibido           = elServicio.Add(elProductoParaInsertar);

            return(CreatedAtRoute("GetProduct",
                                  new
            {
                id = elIdRecibido
            }, elProductoParaInsertar));
        }
        public IActionResult PatchProduct(int id, [FromBody] JsonPatchDocument <ProductUpdate> parchesAlProducto)
        {
            var elServicio          = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
            var elResultadoRecibido = elServicio.QryPorId(id);

            if (elResultadoRecibido != null)
            {
                //var elResultadoDevuelto = _mapper.Map<Products.API.ViewModels.ProductQry>(elResultadoRecibido);
                return(ActualizarProductoParcialmente(elResultadoRecibido, parchesAlProducto));
            }
            else
            {
                return(NotFound());
            }
        }
        public IActionResult GetProduct([System.Web.Http.FromUri] int id)
        {
            var elServicio          = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
            var elResultadoRecibido = elServicio.QryPorId(id);

            if (elResultadoRecibido != null)
            {
                var elResultadoDevuelto = _mapper.Map <Products.API.ViewModels.ProductQry>(elResultadoRecibido);
                return(Ok(elResultadoDevuelto));
            }
            else
            {
                return(NotFound());
            }
        }
 public IActionResult PutProduct(int id, [FromBody] Topicos.NorthWnd.Model.Models.Product elProducto)
 {
     if (id == elProducto.ProductId)
     {
         var elServicio = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
         var pudoActualizarElRegistro = elServicio.ActualizarTodoElProducto(id, elProducto);
         if (pudoActualizarElRegistro)
         {
             return(NoContent());
         }
         else
         {
             return(NotFound());
         }
     }
     else
     {
         return(BadRequest());
     }
 }
Exemple #8
0
        private void QryPorRangoPrecio()
        {
            Console.WriteLine("Consulta de producto por rango de precio.");
            Console.WriteLine("--------------------");
            Console.WriteLine("Digite el rango de precio inferior del producto: ");
            var x = ObtenerNumero();

            Console.WriteLine("Digite el rango de precio superior del producto: ");
            var y = ObtenerNumero();

            if (x != null && y != null)
            {
                int a = 0;
                int b = 0;
                try
                {
                    a = (int)x;
                    b = (int)y;
                    var elServicio  = new Topicos.NorthWnd.BL.Logica.Servicio.NWProduct();
                    var elResultado = elServicio.QryPorRangoDePrecio(a, b);
                    if (elResultado != null)
                    {
                        ImprimirListaDeProductos(elResultado);
                    }
                    else
                    {
                        Console.WriteLine($"No se encontró el producto rango de precio con un limite inferior: {a} y  limite superior: {b}. Por favor revise.");
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Ocurrió un error al convertir los argumentos a números. Por favor revise.");
                }
            }
            else
            {
                Console.WriteLine("Ocurrió un error al convertir los argumentos a números. Por favor revise.");
            }
        }