Пример #1
0
        public void RemoveOrderItem(OrderItemIdentity orderItemId)
        {
            if (orderItemId == null)
            {
                throw new DomainException("Order item id cannot be null");
            }

            var orderItem = _orderItems.FirstOrDefault(e => e.Id == orderItemId);

            if (orderItem == null)
            {
                throw new DomainException($"Order detail {orderItemId} does not exist in the order");
            }

            _orderItems.Remove(orderItem);
        }
Пример #2
0
        public void UpdateOrderItem(OrderItemIdentity orderItemId, ProductIdentity productId, decimal unitPrice, int quantity)
        {
            if (orderItemId == null)
            {
                throw new DomainException("Order item id cannot be null");
            }

            var orderItem = _orderItems.FirstOrDefault(e => e.Id == orderItemId);

            if (orderItem == null)
            {
                throw new DomainException($"Order item {orderItemId} does not exist in the order");
            }

            orderItem.ProductId = productId;
            orderItem.UnitPrice = unitPrice;
            orderItem.Quantity  = quantity;
        }