Пример #1
0
        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);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        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;
        }