Exemplo n.º 1
0
        /// <summary>
        ///     Splits a single item into packages
        /// </summary>
        private IEnumerable <List <USPSVolumetrics> > SplitItemIntoPackages(GetShippingOptionRequest.PackageItem item, int packagesNeeded, decimal currentWeight)
        {
            int splitHeight = Convert.ToInt32((GetTotalHeightForCartItem(item)) / packagesNeeded);
            int splitLength = Convert.ToInt32((GetTotalLengthForCartItem(item)) / packagesNeeded);
            int splitWidth  = Convert.ToInt32((GetTotalWidthForCartItem(item)) / packagesNeeded);
            int splitWeight = Convert.ToInt32(currentWeight / packagesNeeded);

            var splitItems = new List <USPSVolumetrics>();

            for (int i = 0; i < packagesNeeded; i++)
            {
                splitItems.Add(new USPSVolumetrics {
                    Height = splitHeight,
                    Length = splitLength,
                    Weight = splitWeight,
                    Width  = splitWidth
                });

                yield return(splitItems);

                splitItems = new List <USPSVolumetrics>();
            }
        }
Exemplo n.º 2
0
        private decimal GetTotalHeightForCartItem(GetShippingOptionRequest.PackageItem item)
        {
            decimal height = item.ShoppingCartItem.Product.Height;

            return((height <= 0 ? 1 : height) * item.ShoppingCartItem.Quantity);
        }
Exemplo n.º 3
0
        private decimal GetTotalLengthForCartItem(GetShippingOptionRequest.PackageItem item)
        {
            decimal length = item.ShoppingCartItem.Product.Length;

            return((length <= 0 ? 1 : length) * item.ShoppingCartItem.Quantity);
        }
Exemplo n.º 4
0
 private async Task <decimal> GetHomeDeliveryCostOfItem(GetShippingOptionRequest.PackageItem packageItem)
 {
     return(await GetCostAsync(packageItem.Product.Id, packageItem.ShoppingCartItem.AttributesXml, packageItem.ShoppingCartItem.Quantity));
 }