Ejemplo n.º 1
0
        public async Task DeleteProducto(string id)
        {
            if (await productoRepository.GetProducto(id) == null)
            {
                return;
            }

            await productoRepository.DeleteProducto(id);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public Producto GetProducto(int id)
 {
     return(_repository.GetProducto(id));
 }
        public async Task <IActionResult> GetProductos(int id)
        {
            var producto = await _productoRepository.GetProducto(id);

            return(Ok(producto));
        }
Ejemplo n.º 5
0
 public async Task <Producto> GetProducto(int id)
 {
     return(await _productoRepository.GetProducto(id));
 }