public RetailOrder RemoveFromOrder(ILocation location, string placeCode, IProduct product, decimal qty) { RetailOrderDetail orderDetail = Details.FirstOrDefault(x => x.Location.Guid == location.Guid && x.PlaceCode == placeCode); if (orderDetail != null) { orderDetail.RemoveItem(product, qty); if (orderDetail.Items == null || orderDetail.Items.Length < 1) { Details = Details.Where(x => orderDetail.Items.Any()).ToArray(); } } return(this); }
public RetailOrder AddToOrder(ILocation location, string placeCode, IProduct product, decimal qty) { RetailOrderDetail orderDetail = Details.FirstOrDefault(x => x.Location.Guid == location.Guid && x.PlaceCode == placeCode); if (orderDetail == null) { orderDetail = new RetailOrderDetail { Location = new Location(location), PlaceCode = placeCode }; Details = Details.Union(new[] { orderDetail }).ToArray(); } orderDetail.AddItem(product, qty); return(this); }