public void RemoveOrderLine(Guid orderLineId) { var orderLine = OrderLines.FirstOrDefault(x => x.Id == orderLineId); if (orderLine == null) { throw new InvalidOperationException("OrderLine does not exist"); } _orderLines.Remove(orderLine); AddEvent(new BookOrderLineRemovedEvent(orderLine.Id, Id)); }
public void AddProduct(Product product) { OrderLine orderLine = OrderLines.FirstOrDefault(x => x.Product.Equals(product)); if (orderLine == null) { OrderLines.Add(new OrderLine(product, _rebatePolicy)); } else { orderLine.IncreaseQuantity(_rebatePolicy); } }
public void DecrementProduct(Product product) { OrderLine orderLine = OrderLines.FirstOrDefault(o => o.Product.Equals(product)); if (orderLine != null) { orderLine.Amount--; if (orderLine.Amount < 1) { RemoveProduct(product); } } }
public void UpdateOrderLinePrice(Guid orderLineId, decimal price) { var orderLine = OrderLines.FirstOrDefault(x => x.Id == orderLineId); if (orderLine == null) { throw new InvalidOperationException("OrderLine does not exist"); } orderLine.UpdatePrice(price); AddEvent(new BookOrderLinePriceEditedEvent(Id, orderLine.Id, orderLine.Price)); }
public void AddProduct(Product product) { OrderLine orderLine = OrderLines.FirstOrDefault(o => o.Product.Equals(product)); if (orderLine is null) { OrderLines.Add(new OrderLine(product)); } else { orderLine.Amount++; } }
public void RemoveProduct(Product product) { OrderLines.Remove(OrderLines.FirstOrDefault(o => o.Product.Equals(product))); }
public bool OrderlineValueIs(Guid itemId, Money value) { var orderLine = OrderLines.FirstOrDefault(line => line.ItemId == itemId); return(orderLine != null && orderLine.Value.Equals(value)); }
/// <summary> /// Gets the order line of the provided item. /// </summary> /// <param name="orderLinesItem">The item of the order line to get.</param> /// <returns>The order line of the provided item.</returns> public OrderLine GetItemsOrderLine(Item orderLinesItem) { return(OrderLines.FirstOrDefault(line => line.Item.Sku == orderLinesItem.Sku)); }
/// <summary> /// Increments the quantity of the provided item's order line. /// </summary> /// <param name="itemToIncrement">The item to increment the quantity of.</param> public void IncrementItemQty(Item itemToIncrement) { OrderLines.FirstOrDefault(line => line.Item.Sku == itemToIncrement.Sku).Qty++; }