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));
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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));
        }
Пример #5
0
        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++;
            }
        }
Пример #6
0
 public void RemoveProduct(Product product)
 {
     OrderLines.Remove(OrderLines.FirstOrDefault(o => o.Product.Equals(product)));
 }
Пример #7
0
        public bool OrderlineValueIs(Guid itemId, Money value)
        {
            var orderLine = OrderLines.FirstOrDefault(line => line.ItemId == itemId);

            return(orderLine != null && orderLine.Value.Equals(value));
        }
Пример #8
0
 /// <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));
 }
Пример #9
0
 /// <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++;
 }