public void RemoverLinea(int productoId) { LineaCarroCompras linea = BuscarLinea(productoId); if (linea == null) { throw new Exception("No existe el producto"); } //this.detalle.RemoveAll(l => l.Producto.Id == productoId); }
public void AgregarLinea(Producto producto) { LineaCarroCompras linea = this.BuscarLinea(producto.Id); if (linea == null) { this.detalle.Add(new LineaCarroCompras { Producto = producto, Cantidad = 1 }); } else { linea.Cantidad += 1; } }
public void ActualizarLinea(int productoId, int cantidad) { LineaCarroCompras linea = BuscarLinea(productoId); if (linea == null) { throw new Exception("No existe el producto"); } if (cantidad == 0) { this.RemoverLinea(productoId); } linea.Cantidad = cantidad; }