public async Task DeletePreventa(string id)
        {
            if (await preventaRepository.GetPreventa(id) == null)
            {
                return;
            }

            await preventaRepository.DeletePreventa(id);
        }
        public async Task <Factura> CreateFactura(FacturaDTO factura)
        {
            Producto producto = await productoRepository.GetProducto(factura.ProductoId);

            if (producto == null)
            {
                return(null);
            }

            Preventa preventa = await preventaRepository.GetPreventa(factura.PreventaId);

            if (preventa == null)
            {
                return(null);
            }

            Factura nuevaFactura = new Factura
            {
                Preventa     = preventa,
                Producto     = producto,
                FacturaFecha = DateTime.UtcNow,
                Cantidad     = factura.CantidadProducto,
                Total        = producto.ValorUnitario * factura.CantidadProducto
            };

            return(await facturaRepository.CreateFactura(nuevaFactura));
        }