private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address, DeliveryOptionType type)
        {
            DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                List <DeliveryOption> result = new List <DeliveryOption>();
                var proxy = ServiceClientProvider.GetShippingServiceProxy();
                pickupAlternativesResponse =
                    proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03
                {
                    CountryCode = Country,
                    State       = string.Empty
                })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

                if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null)
                {
                    result.AddRange(
                        from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                        orderby po.ID
                        select new DeliveryOption(po, true));
                }
                return(result);
            }
            return(null);
        }
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country,
                                                                           string locale,
                                                                           ShippingAddress_V01 address)
        {
            var deliveryOptions = new List <DeliveryOption>();
            var proxy           = ServiceClientProvider.GetShippingServiceProxy();
            //Look if there is a postal code provided:

            DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

            pickupAlternativesResponse =
                proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03
            {
                CountryCode = address.Address.Country,
                State       = address.Address.StateProvinceTerritory
            })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

            if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null)
            {
                deliveryOptions.AddRange(
                    from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                    select new DeliveryOption(po));
                Array.ForEach(deliveryOptions.ToArray(), a => a.Address = getAddress(a.Name, a.State));
            }

            return(deliveryOptions);
        }
Example #3
0
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address, DeliveryOptionType type)
        {
            DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

            if (type == DeliveryOptionType.PickupFromCourier)
            {
                List <DeliveryOption> result = new List <DeliveryOption>();
                var proxy = ServiceClientProvider.GetShippingServiceProxy();
                pickupAlternativesResponse =
                    proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03
                {
                    CountryCode = Country,
                    State       = string.Empty
                })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

                if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null)
                {
                    bool courier = false;
                    if (type == DeliveryOptionType.PickupFromCourier)
                    {
                        courier = true;
                    }
                    result.AddRange(
                        from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                        select new DeliveryOption(po, courier));
                    Array.ForEach(result.ToArray(), a => a.Address = getAddress(pickupAlternativesResponse, a.Id));
                }

                return(result);
            }
            else
            {
                List <DeliveryOption> result = new List <DeliveryOption>();
                var proxy = ServiceClientProvider.GetShippingServiceProxy();
                DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01();
                request.Country = Country;
                request.State   = (address != null && address.Address != null &&
                                   !string.IsNullOrEmpty(address.Address.StateProvinceTerritory))
                                    ? address.Address.StateProvinceTerritory
                                    : "Москва";
                request.Locale = locale;
                ShippingAlternativesResponse_V01 response =
                    proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01;
                foreach (ShippingOption_V01 option in response.DeliveryAlternatives)
                {
                    DeliveryOption currentOption = new DeliveryOption(option);
                    currentOption.Name          = option.Description;
                    currentOption.WarehouseCode = option.WarehouseCode;
                    currentOption.State         = request.State;
                    currentOption.displayIndex  = option.DisplayOrder;
                    currentOption.DisplayName   = option.Description;
                    result.Add(currentOption);
                }
                //result.Sort((x, y) => x.displayIndex.CompareTo(y.displayIndex));
                return(result.OrderBy(d => d.displayIndex.ToString() + "_" + d.DisplayName).ToList());
            }
        }
Example #4
0
        private static List <DeliveryOption> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address)
        {
            List <DeliveryOption> deliveryOptions = new List <DeliveryOption>();
            var proxy = ServiceClientProvider.GetShippingServiceProxy();
            //Look if there is a postal code provided:

            DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

            pickupAlternativesResponse = proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03()
            {
                CountryCode = address.Address.Country
            })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

            if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null)
            {
                deliveryOptions.AddRange(
                    from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                    select new DeliveryOption(po));
            }

            return(deliveryOptions);
        }
Example #5
0
        private static Address_V01 getAddress(DeliveryPickupAlternativesResponse_V03 DPA, int id)
        {
            var address = DPA.DeliveryPickupAlternatives.Where(x => x.ID == id).Select(x => x.PickupAddress.Address).First();

            return(address);
        }
        public override List <DeliveryOption> GetDeliveryOptions(DeliveryOptionType type, ShippingAddress_V01 address)
        {
            const string CacheKeyPickup = "DeliveryOptions__CN";
            const string CacheKeyPickupFromThirdParty = "PickupThirdParty_CN";

            List <DeliveryOption> deliveryOptions = null;

            if (type == DeliveryOptionType.Pickup)
            {
                deliveryOptions = HttpRuntime.Cache[CacheKeyPickup] as List <DeliveryOption>;
                if (deliveryOptions == null)
                {
                    deliveryOptions = base.GetDeliveryOptions(type, address);
                    if (deliveryOptions != null)
                    {
                        Array.ForEach(deliveryOptions.ToArray(),
                                      p => p.Description = string.Format("{0}-{1}", p.State, p.Description));

                        HttpRuntime.Cache.Insert(CacheKeyPickup,
                                                 deliveryOptions,
                                                 null,
                                                 DateTime.Now.AddMinutes(SHIPPINGINFO_CACHE_MINUTES),
                                                 Cache.NoSlidingExpiration,
                                                 CacheItemPriority.NotRemovable,
                                                 null);
                    }
                }
                return(deliveryOptions);
            }
            else if (type == DeliveryOptionType.PickupFromCourier)
            {
                deliveryOptions = HttpRuntime.Cache[CacheKeyPickupFromThirdParty] as List <DeliveryOption>;
                if (deliveryOptions == null)
                {
                    deliveryOptions = new List <DeliveryOption>();
                    var proxy = ServiceClientProvider.GetShippingServiceProxy();
                    //Look if there is a postal code provided:

                    DeliveryPickupAlternativesResponse_V03 pickupAlternativesResponse = null;

                    pickupAlternativesResponse =
                        proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V03
                    {
                        CountryCode = address.Address.Country,
                        State       = address.Address.StateProvinceTerritory
                    })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V03;

                    if (pickupAlternativesResponse != null &&
                        pickupAlternativesResponse.DeliveryPickupAlternatives != null)
                    {
                        deliveryOptions.AddRange(
                            from po in pickupAlternativesResponse.DeliveryPickupAlternatives
                            select new DeliveryOption(po));
                    }
                    HttpRuntime.Cache.Insert(CacheKeyPickupFromThirdParty,
                                             deliveryOptions,
                                             null,
                                             DateTime.Now.AddMinutes(SHIPPINGINFO_CACHE_MINUTES),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.NotRemovable,
                                             null);
                }
                return(deliveryOptions);
            }
            return(null);
        }