コード例 #1
0
        public RetailOrderDetail AddItem(IProduct product, decimal qty)
        {
            RetailOrderItem item = Items.FirstOrDefault(x => x.Product.Guid == product.Guid);

            if (item == null)
            {
                item  = new RetailOrderItem(product);
                Items = Items.Union(new[] { item }).ToArray();
            }

            item.Quantity += qty;
            return(this);
        }
コード例 #2
0
        public RetailOrderDetail RemoveItem(IProduct product, decimal qty)
        {
            RetailOrderItem item = Items.FirstOrDefault(x => x.Product.Guid == product.Guid);

            if (item != null)
            {
                item.Quantity -= qty;

                if (item.Quantity < 1)
                {
                    Items = Items.Where(x => x.Quantity > 0).ToArray();
                }
            }

            return(this);
        }