/**********************Minimizing the list*************************/ public void minimize(ProductSale sale) { bool found = false; if (this.data == null || this.data.Count == 0) { data.Add(sale); } else { for (int i = 0; i < data.Count && !found; i++) { if (data.ElementAt(i).ProductID == sale.ProductID) { data.ElementAt(i).Amount += sale.Amount; found = true; } } if (!found) { data.Add(sale); } } }
public void removeProductSale(ProductSale sale) { data.Remove(sale); }
/*************************/ public void addProductSale(ProductSale sale) { minimize(sale); }