public void AddVenta(Venta venta)
        {
            var newVenta = new Venta();
            newVenta.clienteId = venta.clienteId;
            
            // newVenta.Cliente = venta.Cliente;
            newVenta.Fecha = venta.Fecha;
            newVenta.Total = venta.Total;
            newVenta.ComprobateId = venta.ComprobateId;
            //newVenta.TipoDocumento = venta.TipoDocumento;
            
            foreach (var item in venta.detalleVenta)
            {
                var detalle = new DetalleVenta();
                detalle.Cantidad = item.Cantidad;
                detalle.ProductoId = item.ProductoId;

                detalle.Precio = item.Precio;//TIPO DOC

                newVenta.detalleVenta.Add(detalle);
            }


            _context.Ventas.Add(newVenta);
            _context.SaveChanges();
        }
        protected void lvProductos_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "addProducto")
            {
                var productoId = Int32.Parse(e.CommandArgument.ToString());

                var producto = ProductoService.GetProductoById(productoId);

                var venta = GetVenta();

                var existe = venta.detalleVenta
                    .SingleOrDefault(i => i.ProductoId.Equals(productoId));

                if (existe == null)
                {
                    var itemPedido = new DetalleVenta()
                    {
                        VentaId = venta.Id,
                        Cantidad = 1,
                        producto = producto,
                        ProductoId = productoId,
                        Precio = producto.PrecioUnitarioDeVenta
                    };
                    venta.detalleVenta.Add(itemPedido);
                }
                else
                {
                    existe.Cantidad += 1;
                }

                BindVenta(venta);

                Cache.Insert("venta", venta);

            }
        }