public void DeleteProduct(int ProductID) { ProductAdded product_deleted = new ProductAdded(); foreach (var productAdded in productsList) { if (productAdded.ProductAddedID == ProductID) { product_deleted = productAdded; break; } } productsList.Remove(product_deleted); }
public void AddProduct(int ProductID) { var existing_product = false; foreach (var productAdded in productsList) { if (productAdded.ProductAddedID == ProductID) { productAdded.Count++; existing_product = true; break; } } if (existing_product == false) { ProductAdded productAdded = new ProductAdded() { Count = 1, ProductAddedID = ProductID }; productsList.Add(productAdded); } }