public async Task DeleteProducto(string id) { if (await productoRepository.GetProducto(id) == null) { return; } await productoRepository.DeleteProducto(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)); }
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)); }
public async Task <Producto> GetProducto(int id) { return(await _productoRepository.GetProducto(id)); }