示例#1
0
        public ILineItem LineItemByCode(string code)
        {
            var lineItem = LineItems.FirstOrDefault(x =>
                                                    x.Code.Equals(code, StringComparison.OrdinalIgnoreCase));

            return(lineItem);
        }
示例#2
0
        protected virtual async Task <CartAggregate> InnerAddLineItemAsync(LineItem lineItem, CartProduct product = null, IList <DynamicPropertyValue> dynamicProperties = null)
        {
            var existingLineItem = LineItems.FirstOrDefault(li => li.ProductId == lineItem.ProductId);

            if (existingLineItem != null)
            {
                await InnerChangeItemQuantityAsync(existingLineItem, existingLineItem.Quantity + Math.Max(1, lineItem.Quantity), product);

                existingLineItem.FulfillmentCenterId   = lineItem.FulfillmentCenterId;
                existingLineItem.FulfillmentCenterName = lineItem.FulfillmentCenterName;

                lineItem = existingLineItem;
            }
            else
            {
                lineItem.Id = null;
                Cart.Items.Add(lineItem);
            }

            if (dynamicProperties != null)
            {
                await UpdateCartItemDynamicProperties(lineItem, dynamicProperties);
            }

            return(this);
        }
示例#3
0
        public void RemoveProduct(int productId)
        {
            var item = LineItems.FirstOrDefault(x => x.ProductId == productId);

            if (item != null)
            {
                LineItems.Remove(item);
            }
        }
示例#4
0
        public void Remove(string lineItemId)
        {
            var lineItem = LineItems.FirstOrDefault(li => li.Id == lineItemId);

            if (lineItem != null)
            {
                LineItems.Remove(lineItem);
            }
        }
示例#5
0
        public void Add(LineItem lineItem)
        {
            var existingLineItem = LineItems.FirstOrDefault(li => li.ProductId == lineItem.ProductId);

            if (existingLineItem != null)
            {
                existingLineItem.Quantity += lineItem.Quantity;
            }
            else
            {
                LineItems.Add(lineItem);
            }
        }
示例#6
0
        public LineItem GetLockInSaleItem(LineItem lockInAdjustment)
        {
            var lockInLineItem = LineItems.FirstOrDefault(
                lineItem => lineItem.TradeMoney.Currency == lockInAdjustment.TradeMoney.Currency &&
                lineItem.LineItemType != ItemType.LockInSaleAdjustment);

            if (lockInLineItem == null)
            {
                throw new ArgumentException(string.Format(
                                                "Unable to retrieve lock-in sale item for lock-in adjustment LineItemId: {0}", lockInAdjustment.Id));
            }

            return(lockInLineItem);
        }
示例#7
0
        public void AddProduct(int productId, int qty, double price)
        {
            var item = LineItems.FirstOrDefault(x => x.ProductId == productId);

            if (item != null)
            {
                item.Quantity += qty;
            }
            else
            {
                LineItems.Add(new OrderLineItem {
                    ProductId = productId, Quantity = qty, Price = price, OrderId = OrderId
                });
            }
        }
示例#8
0
        public void RemoveProduct(int productId)
        {
            var item = LineItems.FirstOrDefault(x => x.ProductId == productId);

            if (item != null)
            {
                LineItems.Remove(item);
            }

            /* veya */

            /*foreach (var item in LineItems)
             * {
             *  if (item.ProductId == productId)
             *  {
             *      LineItems.Remove(item);
             *      break;
             *  }
             * }*/
        }
示例#9
0
 public FinAnalyzerLineItem LineItem(string inventoryID)
 {
     return(LineItems.FirstOrDefault(x => x.InventoryID == inventoryID));
 }