Esempio n. 1
0
        /// <scess flag.ummary>
        ///     Gets the localities for a city from service.
        ///     </summary>
        ///     <param name="city">City name.</param>
        ///     <returns>Succes flag.</returns>
        private bool LookupLocalities(string city)
        {
            bool lookedUp = false;

            dnlLocality.Items.Clear();
            dnlStreetType.Items.Clear();
            dnlStreet.Items.Clear();
            dnlStreet.Text = string.Empty;
            dnlPostCode.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                // We use the city field from service to store the locality info
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var locality in lookupResults)
                    {
                        dnlLocality.Items.Add(new ListItem(locality));
                    }
                    dnlLocality.Items.Insert(0,
                                             new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlLocality.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    dnlCity.Focus();
                }
            }
            return(lookedUp);
        }
        private bool LookupCities(String zipCode)
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            var provider = ShippingProvider.GetShippingProvider(_countryCode);

            if (provider != null)
            {
                var lookupResults = provider.LookupCitiesByZip(_countryCode, zipCode);
                if (null != lookupResults && lookupResults.Count > 0)
                {
                    for (int i = 0; i < lookupResults.Count; i++)
                    {
                        dnlCity.Items.Insert(i, new ListItem(lookupResults[i].City));
                    }
                    dnlCity.Items.Insert(0, new ListItem(string.Empty, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    txtPostCode.Focus();
                    //blErrors.Items.Add(PlatformResources.GetGlobalResourceString("ErrorMessage", "InvalidZipCode"));
                }
            }

            return(lookedUp);
        }
Esempio n. 3
0
        /// <summary>
        ///     Gets the cities from service.
        /// </summary>
        /// <returns>Success flag.</returns>
        private bool LookupCities(string state)
        {
            dnlCity.Items.Clear();
            dnlRegion.Items.Clear();
            dnlPostalCode.Items.Clear();

            var provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                //var lookupResults = provider.GetStreets(ProductsBase.CountryCode, state, district);
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, state);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    var items = (from s in lookupResults select new ListItem {
                        Text = s, Value = s
                    }).ToArray();
                    dnlCity.Items.AddRange(items);
                    dnlCity.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;

                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        ///     Gets postal codes
        /// </summary>
        /// <param name="state"></param>
        /// <param name="district"></param>
        /// <param name="city"></param>
        /// <returns></returns>
        private bool LookupPostalCodes(string state, string district, string city)
        {
            dnlPostalCode.Items.Clear();
            var provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetZipCodes(ProductsBase.CountryCode, state, district, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    var items = (from s in lookupResults select new ListItem {
                        Text = s, Value = s
                    }).ToArray();
                    dnlPostalCode.Items.AddRange(items);
                    dnlPostalCode.SelectedIndex = 0;
                    if (dnlPostalCode.Items.Count == 1)
                    {
                        dnlPostalCode.SelectedIndex = 0;
                    }
                    else
                    {
                        dnlPostalCode.Items.Insert(0,
                                                   new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                        dnlPostalCode.SelectedIndex = 0;
                    }
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 5
0
        private bool LookupVillages(string state, string city)
        {
            bool lookedUp = false;

            dnlVillage.Items.Clear();

            var provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetCountiesForCity(ProductsBase.CountryCode, state, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var village in lookupResults)
                    {
                        if (string.IsNullOrWhiteSpace(village))
                        {
                            continue;
                        }

                        dnlVillage.Items.Add(new ListItem(village, village));
                    }
                    dnlVillage.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlVillage.SelectedIndex = 0;
                    lookedUp = true;
                }
            }

            return(lookedUp);
        }
        private bool LookupCity(string state, string county)
        {
            IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider == null)
            {
                return(false);
            }

            string city = provider.GetAddressField(new AddressFieldForCountryRequest_V01()
            {
                AddressField = AddressPart.CITY,
                Country      = ProductsBase.CountryCode,
                State        = state,
                County       = county
            }).FirstOrDefault();

            if (city != null)
            {
                txtCity.Text = city;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool LookupStates()
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            dnlSuburb.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetStatesForCountry(ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    //TR compatibility with old and new version of data.
                    lookupResults.Remove("-");
                    foreach (var city in lookupResults)
                    {
                        dnlCity.Items.Add(new ListItem(city));
                    }
                    dnlCity.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
        private bool LookupPostalCodes(string state, string city, string district)
        {
            bool lookedUp = false;

            dnlPostalCode.Items.Clear();
            var provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                List <string> lookupResults = provider.GetZipsForStreet(ProductsBase.CountryCode, state, city, district);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var street in lookupResults)
                    {
                        dnlPostalCode.Items.Add(new ListItem(street));
                    }
                    dnlPostalCode.Items.Insert(0,
                                               new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlPostalCode.SelectedIndex = 0;
                    lookedUp = true;
                }
            }

            return(lookedUp);
        }
        private bool LookupCities(string postCode)
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            var provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.LookupCitiesByZip(ProductsBase.CountryCode,
                                                               txtPostCode.Text);
                if (null != lookupResults && lookupResults.Count > 0)
                {
                    for (int i = 0; i < lookupResults.Count; i++)
                    {
                        dnlCity.Items.Insert(i, new ListItem(lookupResults[i].City));
                    }
                    dnlCity.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    txtPostCode.Focus();
                }
            }

            return(lookedUp);
        }
Esempio n. 10
0
        private bool AVSAddressValidationCheck(out string errorCode,
                                               out ServiceProvider.AddressValidationSvc.Address avsAddress)
        {
            errorCode  = string.Empty;
            avsAddress = null;

            if (ProductsBase.CountryCode.Equals("US"))
            {
                IShippingProvider provider = ShippingProvider.GetShippingProvider("US");
                if (provider != null)
                {
                    return(provider.ValidateAddress(_shippingAddr, out errorCode,
                                                    out avsAddress));
                }
            }
            else if (ProductsBase.CountryCode.Equals("PR"))
            {
                IShippingProvider provider = ShippingProvider.GetShippingProvider("PR");
                if (provider != null)
                {
                    return(provider.ValidateAddress(_shippingAddr, out errorCode,
                                                    out avsAddress));
                }
            }



            return(true);
        }
Esempio n. 11
0
        public int Save(ref AddressViewModel address, string memberId, string locale)
        {
            var shippingProvider = ShippingProvider.GetShippingProvider(locale.Substring(3));

            if (shippingProvider != null)
            {
                //check if the address exist
                var addressToSave = ModelConverter.ConvertAddressViewModelToShippingAddress(address);
                if (locale == "zh-CN")
                {
                    addressToSave.Address.Line3 = string.Empty;
                    addressToSave.Address.Line4 = string.Empty;
                }
                var existing = shippingProvider.GetShippingAddressFromAddressGuidOrId(address.CloudId, 0);
                if (null != existing)
                {
                    addressToSave.ID = existing.ID;
                }
                var shippingAddressId = shippingProvider.SaveShippingAddress(memberId, locale, addressToSave, false, true, false);
                if (shippingAddressId > 0)
                {
                    var savedAddress = shippingProvider.GetShippingAddressFromAddressGuidOrId(address.CloudId, 0);
                    address.LastUpdatedDate = savedAddress.Created;
                    address = ModelConverter.ConvertShippingAddressToAddressViewModel(savedAddress);
                    address.CustomShippingMethods = ModelConverter.GetCustomShippingMethods(memberId, savedAddress,
                                                                                            locale);
                }
                return(shippingAddressId);
            }
            return(0);
        }
        private bool LookupCountySuburb(string state, string city)
        {
            bool lookedUp = false;

            dnlCounty.Items.Clear();
            var provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetCountiesForCity(ProductsBase.CountryCode, state, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    lookupResults.ForEach(x => dnlCounty.Items.Add(new ListItem(x)));
                    dnlCounty.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCounty.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    dnlCity.Focus();
                }
            }

            return(lookedUp);
        }
Esempio n. 13
0
        private bool LookupCities()
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetCitiesForState(
                    ProductsBase.CountryCode, ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var city in lookupResults)
                    {
                        dnlCity.Items.Add(new ListItem(city));
                    }
                    dnlCity.Items.Insert(
                        0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
Esempio n. 14
0
        public List <AddressViewModel> Get(GetAddressRequestViewModel request)
        {
            var shippingProvider = ShippingProvider.GetShippingProvider(request.Locale.Substring(3));
            var result           = new List <AddressViewModel>();

            if (shippingProvider != null)
            {
                var shippingAddresses = shippingProvider.GetShippingAddresses(request.MemberId, request.Locale);
                //filter the addresses
                if (request.From != null)
                {
                    shippingAddresses = shippingAddresses.Where(x => x.Created >= request.From).ToList();
                }
                if (request.To != null)
                {
                    shippingAddresses = shippingAddresses.Where(x => x.Created <= request.To).ToList();
                }
                if (shippingAddresses != null && shippingAddresses.Any())
                {
                    result.AddRange(
                        shippingAddresses.Select(
                            a => ModelConverter.ConvertAddressToViewModel(a, false, request.MemberId, request.Locale)));
                }
            }
            return(result);
        }
        /// <summary>
        ///     Gets the cities from service.
        /// </summary>
        /// <returns>Success flag.</returns>
        private bool LookupCities()
        {
            dnlCity.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                // For Serbia, state code is same as country code in db
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var cityZip in lookupResults)
                    {
                        // value is postal code, text is city name
                        dnlCity.Items.Add(new RadComboBoxItem(cityZip.Split(',')[1],
                                                              cityZip.Split(',')[0]));
                    }
                    dnlCity.Items.Insert(0, new RadComboBoxItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    return(true);
                }
            }
            return(false);
        }
        private bool LookupPostal(string state, string city, string county)
        {
            bool lookedUp = false;

            dnlPostalCode.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetZipsForCounty(ProductsBase.CountryCode, state, city, county);

                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var zip in lookupResults)
                    {
                        dnlPostalCode.Items.Add(new ListItem(zip));
                    }
                    if (dnlPostalCode.Items.Count != 1)
                    {
                        dnlPostalCode.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                        dnlPostalCode.SelectedIndex = 0;
                    }
                    lookedUp = true;
                }
                else
                {
                    dnlCounty.Focus();
                }
            }
            return(lookedUp);
        }
 private bool LookupState(string zipCode)
 {
     dnlState.Items.Clear();
     if (!string.IsNullOrEmpty(zipCode) && zipCode.Trim().Length > 3)
     {
         IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);
         if (provider != null)
         {
             var lookupResults = provider.LookupCitiesByZip(ProductsBase.CountryCode, zipCode.Substring(0, 3));
             if (lookupResults != null && lookupResults.Count > 0)
             {
                 var items = (from s in lookupResults select new ListItem {
                     Text = s.State, Value = s.State
                 }).ToArray();
                 this.dnlState.Items.AddRange(items);
                 if (lookupResults.Count > 1)
                 {
                     this.dnlState.Items.Insert(0, new ListItem(this.GetLocalResourceObject("Select") as string, string.Empty));
                     this.dnlState.SelectedIndex = 0;
                     dnlState.Focus();
                 }
                 else
                 {
                     txtArea.Focus();
                 }
                 this.dnlState.SelectedIndex = 0;
                 return(true);
             }
         }
     }
     return(false);
 }
        private bool LookupCounties(string state, string city)
        {
            bool lookedUp = false;

            dnlDistrict.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetStreetsForCity(ProductsBase.CountryCode, state, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var district in lookupResults)
                    {
                        string[] item = district.Split('-');
                        dnlDistrict.Items.Add(new ListItem(item[1], item[0]));
                    }
                    dnlDistrict.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlDistrict.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    dnlCity.Focus();
                }
            }
            return(lookedUp);
        }
        /// <summary>
        ///     Get the states from provider.
        /// </summary>
        /// <returns>Success flag.</returns>
        private bool LookupStates()
        {
            bool lookedUp = false;

            dnlState.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetStatesForCountry(ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    var items = (from s in lookupResults select new ListItem {
                        Text = s, Value = s
                    }).ToArray();
                    dnlState.Items.AddRange(items);
                    dnlState.Items.Insert(
                        0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlState.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
Esempio n. 20
0
 private bool LookupAddress(string Zipcode)
 {
     if (!string.IsNullOrEmpty(Zipcode))
     {
         IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);
         if (provider != null)
         {
             var Address = ShippingProvider_JP.GetAddressByPostalCode(ProductsBase.CountryCode, Zipcode);
             if (Address != null && Address.AddressDetails != null && Address.AddressDetails.Count > 0)
             {
                 string        CityTown = Address.AddressDetails[0].City.ToString();
                 List <string> words    = Regex.Split(CityTown, @"\W+").ToList();
                 txtCity.Text = words[0].ToString();
                 if (words.Count > 1)
                 {
                     txtTown.Text   = words[1].ToString();
                     txtStreet.Text = Address.AddressDetails[0].Street.ToString();
                 }
                 else
                 {
                     txtTown.Text = Address.AddressDetails[0].Street.ToString();
                 }
                 txtPrefecture.Text = Address.AddressDetails[0].State.ToString();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
/*
 *      private bool LookupProvince(string zipCode)
 *      {
 *          bool lookedUp = false;
 *          dnlState.Items.Clear();
 *          if (!string.IsNullOrEmpty(zipCode))
 *          {
 *              IShippingProvider provider = ShippingProvider.GetShippingProvider(
 *                      ProductsBase.CountryCode);
 *              if (provider != null)
 *              {
 *                  var lookupResults = provider.LookupCitiesByZip(ProductsBase.CountryCode, zipCode);
 *                  if (lookupResults != null && lookupResults.Count > 0)
 *                  {
 *                      foreach (var province in lookupResults)
 *                      {
 *                          string[] state = province.State.Split('-');
 *                          dnlState.Items.Add(new ListItem(state[0], state[1]));
 *                      }
 *
 *                      if (lookupResults.Count > 1)
 *                      {
 *                          dnlState.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, "0"));
 *                      }
 *                      dnlState.SelectedIndex = 0;
 *                      lookedUp = true;
 *                  }
 *              }
 *          }
 *          return lookedUp;
 *      }
 */
        /*     protected void txtPostCode_TextChanged(object sender, EventArgs e)
         *   {
         *       dnlState.Items.Clear();
         *       if (!string.IsNullOrEmpty(dnlPostCode.SelectedItem.Text))
         *       {
         *           LookupProvince(txtPostCode.Text);
         *       }
         *   }*/

        private bool LookupStates()
        {
            bool lookedUp = false;

            dnlState.Items.Clear();
            IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetStatesForCountry(ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var province in lookupResults)
                    {
                        string[] state = province.Split('-');
                        dnlState.Items.Add(new ListItem(state[0], state[1]));

                        //dnlState.Items.Add(new ListItem(province));
                    }
                    dnlState.Items.Insert(0, new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlState.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
        private bool LookupProvince()
        {
            bool lookedUp = false;

            dnlProvince.Items.Clear();
            dnlSuburb.Items.Clear();
            dnlSuburb.Text = string.Empty;
            dnlPostalCode.Items.Clear();

            IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetStatesForCountry(ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Any())
                {
                    foreach (var province in lookupResults)
                    {
                        dnlProvince.Items.Add(new ListItem(province));
                    }
                    dnlProvince.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlProvince.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
Esempio n. 23
0
        private bool LookupZones(string state, string county)
        {
            bool lookedUp = false;

            dnlZone.Items.Clear();

            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider == null)
            {
                return(lookedUp);
            }

            var lookupResults = provider.GetCountiesForCity(ProductsBase.CountryCode, state, county);

            if (lookupResults != null && lookupResults.Count > 0)
            {
                foreach (var zone in lookupResults)
                {
                    if (!String.IsNullOrEmpty(zone))
                    {
                        dnlZone.Items.Add(new ListItem(zone, zone));
                    }
                }
                lookedUp = true;
            }

            dnlZone.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
            dnlZone.SelectedIndex = 0;

            return(lookedUp);
        }
        private bool LookupCities(string state)
        {
            bool lookedUp = false;

            ddlCity.Items.Clear();
            IShippingProvider provider = ShippingProvider.
                                         GetShippingProvider(_countryCode);

            if (provider != null)
            {
                if (!state.Equals(string.Empty))
                {
                    List <string> lookupResults = provider.GetCitiesForState(_countryCode, state);
                    if (null != lookupResults && lookupResults.Count > 0)
                    {
                        for (int i = 0; i < lookupResults.Count; i++)
                        {
                            ddlCity.Items.Insert(i, new ListItem(lookupResults[i]));
                        }
                        ddlCity.Items.Insert(0,
                                             new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                        ddlCity.SelectedIndex = 0;
                        lookedUp = true;
                    }
                }
            }

            return(lookedUp);
        }
Esempio n. 25
0
        public static ShippingInfo_V01 GetShippingInfoFromCart(MyHLShoppingCart cart)
        {
            var shipping     = new ShippingInfo_V01();
            var deliveryInfo = cart.DeliveryInfo;

            if (deliveryInfo == null)
            {
                shipping.FreightVariant = HLConfigManager.Configurations.DOConfiguration.IsChina
                                              ? "EXP"
                                              : ShippingProvider.GetShippingProvider(cart.CountryCode).GetFreightVariant(null);
                shipping.ShippingMethodID = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCode;
                shipping.WarehouseCode    = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse;
            }
            else
            {
                shipping.FreightVariant = HLConfigManager.Configurations.DOConfiguration.IsChina
                                              ? deliveryInfo.AddressType
                                              : deliveryInfo.FreightVariant;
                shipping.ShippingMethodID = deliveryInfo.FreightCode;
                shipping.WarehouseCode    = deliveryInfo.WarehouseCode;
            }
            shipping.Address = addressNotValid(deliveryInfo) ? CreateDefaultAddress() : ObjectMappingHelper.Instance.GetToOrder(deliveryInfo.Address.Address);

            var provider = ShippingProvider.GetShippingProvider(null);

            if (provider != null)
            {
                provider.GetDistributorShippingInfoForHMS(cart, shipping);
            }
            return(shipping);
        }
 private ShoppingCartRuleResult PerformRules(ShoppingCart_V02 cart, ShoppingCartRuleReason reason, ShoppingCartRuleResult result)
 {
     if (reason == ShoppingCartRuleReason.CartItemsAdded || reason == ShoppingCartRuleReason.CartItemsRemoved ||
         reason == ShoppingCartRuleReason.CartCalculated || reason == ShoppingCartRuleReason.CartCreated ||
         reason == ShoppingCartRuleReason.CartWarehouseCodeChanged || reason == ShoppingCartRuleReason.CartFreightCodeChanging)
     {
         if (cart != null)
         {
             var myHLCart = cart as MyHLShoppingCart;
             if (myHLCart != null && myHLCart.DeliveryInfo.Option == ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping)
             {
                 var shippingProvider = ShippingProvider.GetShippingProvider(Country);
                 //get URB locales GetFreightCodeAndWarehouseFromService
                 var FCandWH = shippingProvider.GetFreightCodeAndWarehouse(myHLCart.DeliveryInfo.Address);
                 if (FCandWH != null && FCandWH[0] == "URB")
                 {
                     //User Story 229708
                     //a.Orders under 500.9999 VP = Remains as URB freight code
                     if (myHLCart.VolumeInCart < URBVP)
                     {
                         myHLCart.DeliveryInfo.FreightCode =
                             myHLCart.FreightCode          = "URB";
                     }
                     //b.Order above 501.0000 VP = System should be redirected and calculate PMS freight code instead of URB.
                     else if ((myHLCart.VolumeInCart >= URBVP))
                     {
                         myHLCart.DeliveryInfo.FreightCode =
                             myHLCart.FreightCode          = "PMS";
                     }
                 }
             }
         }
     }
     return(result);
 }
Esempio n. 27
0
 public static List <CustomShippingMethodViewModel> GetCustomShippingMethods(string memberId,
                                                                             ShippingAddress_V01 address, string locale)
 {
     try
     {
         var country          = locale.Substring(3);
         var shippingProvider = ShippingProvider.GetShippingProvider(locale.Substring(3));
         if (shippingProvider == null)
         {
             return(null);
         }
         var deliveryOptions = shippingProvider.GetDeliveryOptionsListForMobileShipping(country, locale,
                                                                                        address, memberId);
         if (null == deliveryOptions || !deliveryOptions.Any())
         {
             return(null);
         }
         var customShippingModels = deliveryOptions.Select(option => new CustomShippingMethodViewModel
         {
             Code       = option.FreightCode,
             Title      = option.Description,
             OrderTypes = "RSO"
         }).ToList();
         return(customShippingModels);
     }
     catch (Exception ex)
     {
         LoggerHelper.Exception("General", ex, "Failed while getting mobile GetCustomShippingMethods");
         return(null);
     }
 }
Esempio n. 28
0
        public bool DeletePickUpLocation(string memberId, PickupViewModel model, string locale)
        {
            IShippingProvider shippingProvider = ShippingProvider.GetShippingProvider(locale.Substring(3));

            if (null != shippingProvider)
            {
                shippingProvider.DeletePickupLocationsPreferences(memberId, model.DeliveryOptionId,
                                                                  model.Address.Country);
            }
            return(true);
        }
Esempio n. 29
0
        public PickupViewModel SavePickUpPreference(string memberId, PickupViewModel model, string locale)
        {
            IShippingProvider shippingProvider = ShippingProvider.GetShippingProvider(locale.Substring(3));

            if (null != shippingProvider)
            {
                model.IDSaved = shippingProvider.SavePickupLocationsPreferences(memberId, false, model.DeliveryOptionId, model.Alias,
                                                                                model.Name, model.Address.Country, model.IsPrimary);
            }

            return(model);
        }
        private DeliveryOption getPrimaryPUFromCourierLocation()
        {
            try
            {
                pickupLocationPreferences =
                    (Page as ProductsBase).GetShippingProvider()
                    .GetPickupLocationsPreferences((Page as ProductsBase).DistributorID,
                                                   (Page as ProductsBase).CountryCode);
                if (pickupLocationPreferences == null)
                {
                    return(null);
                }

                primaryPickupLocationPreference = pickupLocationPreferences.Where(s => s.IsPrimary).First();
                if (null != primaryPickupLocationPreference)
                {
                    var shippingInfo =
                        ShippingProvider.GetShippingProvider(CountryCode)
                        .GetShippingInfoFromID(DistributorID, Locale,
                                               DeliveryOptionType.PickupFromCourier,
                                               primaryPickupLocationPreference.ID, 0);
                    if (null != shippingInfo)
                    {
                        var deliveryOption = new DeliveryOption(shippingInfo.WarehouseCode, shippingInfo.FreightCode,
                                                                DeliveryOptionType.Pickup);
                        if (shippingInfo.Address != null)
                        {
                            deliveryOption.Address = shippingInfo.Address.Address;
                        }

                        if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                        {
                            deliveryOption.Alias       = primaryPickupLocationPreference.PickupLocationNickname;
                            deliveryOption.Id          = primaryPickupLocationPreference.PickupLocationID;
                            deliveryOption.Description = shippingInfo.Name + " " + shippingInfo.Description;
                        }
                        else
                        {
                            deliveryOption.Alias       = shippingInfo.Name;
                            deliveryOption.Id          = primaryPickupLocationPreference.PickupLocationID;
                            deliveryOption.Description = shippingInfo.Description;
                        }
                        return(deliveryOption);
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(null);
        }