public RetailOrderDetail AddItem(IProduct product, decimal qty) { RetailOrderItem item = Items.FirstOrDefault(x => x.Product.Guid == product.Guid); if (item == null) { item = new RetailOrderItem(product); Items = Items.Union(new[] { item }).ToArray(); } item.Quantity += qty; return(this); }
public RetailOrderDetail RemoveItem(IProduct product, decimal qty) { RetailOrderItem item = Items.FirstOrDefault(x => x.Product.Guid == product.Guid); if (item != null) { item.Quantity -= qty; if (item.Quantity < 1) { Items = Items.Where(x => x.Quantity > 0).ToArray(); } } return(this); }