private List <ShippingItem> GetShippingRatesList()
        {
            if (_shoppingCart == null)
            {
                throw new Exception("_shoppingCart == null");
            }
            var lists = new List <ShippingItem>();

            var currencyIso3 = Currency.Iso3;

            var threads       = new List <Thread>();
            var shippingRates = new List <ThreadShippingRate>();
            var totalPrice    = _shoppingCart.TotalPrice;
            var totalDiscount = _shoppingCart.TotalDiscount;

            int i = 1;

            foreach (var item in GetShippingMethodsByGeoMapping(_listMethod))
            {
                int index = 1000 * (int)item.Type + 100 * i++;

                var shippingRate = new ThreadShippingRate(item, index, _countryName, _countryIso2, _zipTo, _cityTo,
                                                          _regionTo, currencyIso3, _shoppingCart, totalPrice, totalDiscount,
                                                          _distance, _pickupId, _orderItems);
                shippingRates.Add(shippingRate);

                var thread = new Thread(shippingRate.GetRate);
                thread.Start();
                threads.Add(thread);
            }

            foreach (var t in threads)
            {
                t.Join();
            }

            foreach (var shippingRate in shippingRates)
            {
                lists.AddRange(shippingRate.ShippingRates);
            }

            return(lists);
        }
Beispiel #2
0
        private List<ShippingListItem> GetShippingRatesList()
        {
            if(_shoppingCart == null)
            {
                throw new Exception("_shoppingCart == null");
            }
            var lists = new List<ShippingListItem>();

            var currencyIso3 = Currency.Iso3;

            var threads = new List<Thread>();
            var shippingRates = new List<ThreadShippingRate>();
            var tempList = UseGeoMapping(_listMethod);
            var totalPrice = _shoppingCart.TotalPrice;
            var totalDiscount = _shoppingCart.TotalDiscount;

            int i = 1;
            foreach (var item in tempList)
            {
                int index = 1000 * (int)item.Type + 100 * i++;

                var shippingRate = new ThreadShippingRate(item, index, _countryName, _countryIso2, _zipTo, _cityTo, _regionTo, currencyIso3, _shoppingCart, totalPrice, totalDiscount, _distance );
                shippingRates.Add(shippingRate);

                var thread = new Thread(shippingRate.GetRate);
                thread.Start();
                threads.Add(thread);
            }

            foreach (var t in threads)
                t.Join();

            foreach (var shippingRate in shippingRates)
            {
                lists.AddRange(shippingRate.ShippingRates);
            }

            return lists;
        }