public void AddProduct(Product product) { if (!ProductsInInvoice.Exists(e => e.ID == product.ID) && product != null) { ProductsInInvoice.Add(product); } else if (product != null) { Product temp = ProductsInInvoice.Find(e => e.ID == product.ID); int qauntitytemp = temp.GetProductPurchasedQuantity() + product.GetProductPurchasedQuantity(); temp.SetProductPurchasedQuantity(qauntitytemp); int index = ProductsInInvoice.FindIndex(e => e.ID == temp.ID); ProductsInInvoice[index] = temp; } }
public void RemoveProduct(int id) => ProductsInInvoice.Remove(ProductsInInvoice.Find(products => products.ID == id));
public Product GetProduct(int id) { return(ProductsInInvoice.Find(product => product.ID == id)); }