public ReturnBuilder AddExchangeItem(Item catalogItem, decimal quantity) { EnsureExchangeOrderCreated(); var lineItem = ExchangeOrder.OrderForms[0].LineItems.FirstOrDefault(x => x.LineItemId == catalogItem.ItemId); if (lineItem == null) { lineItem = CatalogItem2LineItem(catalogItem, quantity); ExchangeOrder.OrderForms[0].LineItems.Add(lineItem); var shipmentItem = CreateEntity <ShipmentItem>(); shipmentItem.LineItem = lineItem; shipmentItem.LineItemId = lineItem.LineItemId; shipmentItem.Quantity = quantity; shipmentItem.Shipment = ExchangeOrder.OrderForms[0].Shipments[0]; ExchangeOrder.OrderForms[0].Shipments[0].ShipmentItems.Add(shipmentItem); ExchangeLineItems.Add(lineItem); } else { lineItem.Quantity += quantity; var shipmentItem = ExchangeOrder.OrderForms[0].Shipments[0].ShipmentItems.First(x => x.LineItemId == lineItem.LineItemId); shipmentItem.Quantity += quantity; } RecalculateExchange(); return(this); }
public ReturnBuilder RemoveExchangeItem(LineItem exchangeLineItem) { ExchangeOrder.OrderForms[0].LineItems.Remove(exchangeLineItem); ExchangeLineItems.Remove(exchangeLineItem); var exchangeShipmentItems = ExchangeOrder.OrderForms[0].Shipments[0].ShipmentItems; exchangeShipmentItems.Remove(exchangeShipmentItems.First(x => x.LineItemId == exchangeLineItem.LineItemId)); RecalculateExchange(); return(this); }