예제 #1
0
        public static int GetTotalNumberOfDeliveredItems(this OrderShippingItem orderShippingItem)
        {
            if (orderShippingItem == null)
            {
                throw new ArgumentNullException("orderShippingItem");
            }

            var result    = 0;
            var shipments = orderShippingItem.OrderShipping.Shipments.ToList();

            for (int i = 0; i < shipments.Count; i++)
            {
                var shipment = shipments[i];
                if (!shipment.DeliveryDateUtc.HasValue)
                {
                    //not delivered yet
                    continue;
                }

                var si = shipment.ShipmentItems
                         .FirstOrDefault(x => x.OrderShippingItemId == orderShippingItem.Id);
                if (si != null)
                {
                    result += si.Quantity;
                }
            }

            return(result);
        }
예제 #2
0
        protected virtual bool HasAccessToOrderShippingItem(OrderShippingItem orderShippingItem)
        {
            if (orderShippingItem == null)
            {
                throw new ArgumentNullException("orderShippingItem");
            }

            if (_workContext.CurrentVendor == null)
            {
                //not a vendor; has access
                return(true);
            }

            var vendorId = _workContext.CurrentVendor.Id;

            return(orderShippingItem.OrderItem.Product.VendorId == vendorId);
        }
예제 #3
0
        public static int GetTotalNumberOfItemsCanBeAddedToShipment(this OrderShippingItem orderShippingItem)
        {
            if (orderShippingItem == null)
            {
                throw new ArgumentNullException("orderShippingItem");
            }

            var totalInShipments = orderShippingItem.GetTotalNumberOfItemsInAllShipment();

            var qtyOrdered = orderShippingItem.Quantity;
            var qtyCanBeAddedToShipmentTotal = qtyOrdered - totalInShipments;

            if (qtyCanBeAddedToShipmentTotal < 0)
            {
                qtyCanBeAddedToShipmentTotal = 0;
            }

            return(qtyCanBeAddedToShipmentTotal);
        }
예제 #4
0
        public static int GetTotalNumberOfItemsInAllShipment(this OrderShippingItem orderShippingItem)
        {
            if (orderShippingItem == null)
            {
                throw new ArgumentNullException("orderShippingItem");
            }

            var totalInShipments = 0;
            var shipments        = orderShippingItem.OrderShipping.Shipments.ToList();

            for (int i = 0; i < shipments.Count; i++)
            {
                var shipment = shipments[i];
                var si       = shipment.ShipmentItems
                               .FirstOrDefault(x => x.OrderShippingItemId == orderShippingItem.Id);
                if (si != null)
                {
                    totalInShipments += si.Quantity;
                }
            }
            return(totalInShipments);
        }