public void RemoveItem(t_product Product) { Item t = null; foreach (Item a in Items) { if (a.Prod.productId == Product.productId) { t = a; } } if (t != null) { Items.Remove(t); } }
public void AddItem(t_product prod) { Boolean iswhat = false; // Create a new item to add to the cart foreach (Item a in Items) { if (a.Prod.productId == prod.productId) { a.Quantity++; iswhat = true; return; } } if (iswhat == false) { Item newItem = new Item(prod); newItem.Quantity = 1; Items.Add(newItem); } }
public void SetItemQuantity(t_product Product, int quantity) { if (quantity == 0) { RemoveItem(Product); return; } foreach (Item a in Items) { if (a.Prod.productId == Product.productId) { a.Quantity = quantity; return; } } }
public void SetLessOneItem(t_product produit) { foreach (Item a in Items) { if (a.Prod.productId == produit.productId) { if (a.Quantity <= 0) { RemoveItem(a.Prod); return; } else { a.Quantity--; return; } } } }
public Item(t_product p) { this.Prod = p; }