public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country, string locale, ShippingAddress_V01 address) { if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.UseXHLTables) { List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); if (!string.IsNullOrEmpty(address.Address.PostalCode)) { var shippingAlternativesResponse = proxy.GetShippingAlternativesForPostalCode(new ServiceProvider.ShippingMexicoSvc.GetShippingAlternativesForPostalCodeRequest(new ServiceProvider.ShippingMexicoSvc.ShippingAlternativesForPostalCodeRequest_V01() { Country = "AR", PostalCode = address.Address.PostalCode })).GetShippingAlternativesForPostalCodeResult as MyHerbalife3.Ordering.ServiceProvider.ShippingMexicoSvc.ShippingAlternativesResponse_V01; if (shippingAlternativesResponse != null && shippingAlternativesResponse.DeliveryAlternatives != null) { deliveryOptions.AddRange(from so in shippingAlternativesResponse.DeliveryAlternatives where !so.ShippingSource.Status.ToUpper().Equals("NOGDO") && !so.ShippingSource.Status.ToUpper().Equals("NODISPONIBLE") select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(so))); } } return(deliveryOptions); } else { return(base.GetDeliveryOptionsListForShipping(Country, locale, address)); } }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country, string locale, MyHerbalife3.Ordering.ServiceProvider.ShippingSvc.ShippingAddress_V01 address) { if (locale.Equals("en-MX")) { base.GetDeliveryOptionsListForShipping(Country, locale, address); } List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); //Look if there is a postal code provided: if (!string.IsNullOrEmpty(address.Address.PostalCode)) { var shippingAlternativesResponse = proxy.GetShippingAlternativesForPostalCode(new ServiceProvider.ShippingMexicoSvc.GetShippingAlternativesForPostalCodeRequest(new ShippingAlternativesForPostalCodeRequest_V01() { PostalCode = address.Address.PostalCode })).GetShippingAlternativesForPostalCodeResult as MyHerbalife3.Ordering.ServiceProvider.ShippingMexicoSvc.ShippingAlternativesResponse_V01; if (shippingAlternativesResponse != null && shippingAlternativesResponse.DeliveryAlternatives != null) { deliveryOptions.AddRange(from so in shippingAlternativesResponse.DeliveryAlternatives where !so.ShippingSource.Status.ToUpper().Equals("NOGDO") && !so.ShippingSource.Status.ToUpper().Equals("NODISPONIBLE") select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(so))); } } return(deliveryOptions); }
public override List <string> GetStatesForCountry(string country) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); var request = new GetAllStatesRequest(); var response = proxy.GetAllStates(request); var result = response.GetAllStatesResult as AllStatesResponse_V01; return(result.StateNames.ToList()); }
public override List <string> GetCitiesForState(string country, string state) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); var request = new MunicipalitiesForStateRequest_V01() { State = state }; var response = proxy.GetMunicipalitiesForState(new GetMunicipalitiesForStateRequest(request)); var result = response.GetMunicipalitiesForStateResult as MunicipalitiesForStateResponse_V01; return(result.Municipalities.ToList()); }
public override List <string> GetStreetsForCity(string country, string state, string city) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); ColoniesForMunicipalityRequest_V01 request = new ColoniesForMunicipalityRequest_V01() { State = state, Municipality = city }; var response = proxy.GetColoniesForMunicipality(new GetColoniesForMunicipalityRequest(request)); var result = response.GetColoniesForMunicipalityResult as ColoniesForMunicipalityResponse_V01; return(result.ColonyNames.ToList()); }
public override string LookupZipCode(string state, string municipality, string colony) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); ZipCodeLookupRequest_V01 request = new ZipCodeLookupRequest_V01() { State = state, Municipality = municipality, Colony = colony }; var response = proxy.GetZipCode(new GetZipCodeRequest(request)); var result = response.GetZipCodeResult as ZipCodeLookupResponse_V01; return(result.ZipCode); }
public override List <PickupLocationPreference_V01> GetPickupLocationsPreferences(string distributorId, string country) { if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.UseXHLTables) { var pickupLocationPreferences = getPickupLocationsPreferencesFromCache(distributorId, country); var pickupLocationPreferencestoRemove = new List <PickupLocationPreference_V01>(); if (pickupLocationPreferences != null && pickupLocationPreferences.Count > 0) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); foreach (PickupLocationPreference_V01 pref in pickupLocationPreferences) { // Checking if the location saved is in db var request = new ServiceProvider.ShippingMexicoSvc.DeliveryOptionForIDRequest_V01() { ID = pref.PickupLocationID, Country = "AR" }; var pickupAlternativesResponse = proxy.GetPickupAlternativeForDeliveryOptionID(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01; if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null && pickupAlternativesResponse.PickupAlternatives.Count > 0) { if (string.IsNullOrEmpty(pref.PickupLocationNickname)) { pref.PickupLocationNickname = pickupAlternativesResponse.PickupAlternatives[0].BranchName; } } else { pickupLocationPreferencestoRemove.Add(pref); } } // Removing the not existing locations in db if (pickupLocationPreferencestoRemove.Count > 0) { foreach (var item in pickupLocationPreferencestoRemove) { DeletePickupLocationsPreferences(item.DistributorID, item.PickupLocationID, item.Country); } } } return(pickupLocationPreferences); } else { return(base.GetPickupLocationsPreferences(distributorId, country)); } }
public override List <DeliveryOption> GetDeliveryOptions(DeliveryOptionType type, MyHerbalife3.Ordering.ServiceProvider.ShippingSvc.ShippingAddress_V01 address) { var locale = Thread.CurrentThread.CurrentCulture.Name; if (locale.Equals("en-MX")) { var mexicoDeliveryOptions = base.GetDeliveryOptions(type, address); if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.HasSpecialEventWareHouse) { RemoveUnauthorizedDeliveryOptions(mexicoDeliveryOptions, locale); } return(mexicoDeliveryOptions); } List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); //Look if there is a postal code provided: if (type == DeliveryOptionType.Pickup) { PickupAlternativesResponse_V01 pickupAlternativesResponse = null; if (!string.IsNullOrEmpty(address.Address.PostalCode)) { pickupAlternativesResponse = proxy.GetPickupAlternativesForPostalCode(new GetPickupAlternativesForPostalCodeRequest(new PickupAlternativesForPostalCodeRequest_V01() { PostalCode = address.Address.PostalCode })).GetPickupAlternativesForPostalCodeResult as PickupAlternativesResponse_V01; } else { pickupAlternativesResponse = proxy.GetPickupAlternativesForColony(new GetPickupAlternativesForColonyRequest(new PickupAlternativesForColonyRequest_V01() { Colony = address.Address.Line3, Municipality = address.Address.City, State = address.Address.StateProvinceTerritory })).GetPickupAlternativesForColonyResult as PickupAlternativesResponse_V01; } if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null) { deliveryOptions.AddRange( from po in pickupAlternativesResponse.PickupAlternatives select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(po))); } } else { if (!string.IsNullOrEmpty(address.Address.PostalCode)) { var shippingAlternativesResponse = proxy.GetShippingAlternativesForPostalCode(new ServiceProvider.ShippingMexicoSvc.GetShippingAlternativesForPostalCodeRequest(new ShippingAlternativesForPostalCodeRequest_V01() { PostalCode = address.Address.PostalCode })).GetShippingAlternativesForPostalCodeResult as MyHerbalife3.Ordering.ServiceProvider.ShippingMexicoSvc.ShippingAlternativesResponse_V01; if (shippingAlternativesResponse != null && shippingAlternativesResponse.DeliveryAlternatives != null) { deliveryOptions.AddRange(from so in shippingAlternativesResponse.DeliveryAlternatives where !so.ShippingSource.Status.ToUpper().Equals("NOGDO") && !so.ShippingSource.Status.ToUpper().Equals("NODISPONIBLE") select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(so))); } } } return(deliveryOptions); }
/// <summary> /// GetPickupLocationsPreferences for a Distributor /// MEXICO ONLY /// </summary> /// <param name="distributorId"></param> /// <param name="country"></param> /// <returns></returns> public override List <PickupLocationPreference_V01> GetPickupLocationsPreferences(string distributorId, string country) { if (Thread.CurrentThread.CurrentCulture.Name.Equals("en-MX")) { var values = base.GetPickupLocationsPreferences(distributorId, country); return(values); } // gets cache key string cacheKey = getPickupLocationPreferenceKey(distributorId, country); HttpSessionState session = HttpContext.Current.Session; bool loadFromService = false; if (null == session[cacheKey]) { loadFromService = true; } List <PickupLocationPreference_V01> PickupLocationPreferences = getPickupLocationsPreferencesFromCache(distributorId, country); List <PickupLocationPreference_V01> PickupLocationPreferencestoRemove = new List <PickupLocationPreference_V01>(); if (PickupLocationPreferences != null && loadFromService == true) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); foreach (PickupLocationPreference_V01 pref in PickupLocationPreferences) { //checking if the location saved is in CUBO DB var option = GetShippingInfoFromID(distributorId, Thread.CurrentThread.CurrentCulture.Name, DeliveryOptionType.Pickup, pref.PickupLocationID, 0); if (option != null) { if (string.IsNullOrEmpty(pref.PickupLocationNickname)) { DeliveryOptionForIDRequest_V01 request = new DeliveryOptionForIDRequest_V01(); request.ID = pref.PickupLocationID; var pickupAlternativesResponse = proxy.GetPickupAlternativeForDeliveryOptionID(new GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as PickupAlternativesResponse_V01; if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null && pickupAlternativesResponse.PickupAlternatives.Count > 0) { pref.PickupLocationNickname = pickupAlternativesResponse.PickupAlternatives[0].BranchName; } } } else { PickupLocationPreferencestoRemove.Add(pref); } } //removing the not existing locations in cubo if (PickupLocationPreferencestoRemove.Count > 0) { foreach (var item in PickupLocationPreferencestoRemove) { DeletePickupLocationsPreferences(item.DistributorID, item.PickupLocationID, item.Country); session["showMessageOnPage"] = "True"; } } session[cacheKey] = PickupLocationPreferences; } return(PickupLocationPreferences); }
public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID) { if (locale.Equals("en-MX")) { return(base.GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID)); } var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); DeliveryOptionForIDRequest_V01 request = new DeliveryOptionForIDRequest_V01(); request.ID = deliveryOptionID; DeliveryOption deliveryOption = null; if (type == DeliveryOptionType.Pickup) { string countryCode = locale.Substring(3, 2); List <PickupLocationPreference_V01> pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode); if (pickupLocationPreference != null && pickupLocationPreference.Count > 0) { var vPickupLocation = pickupLocationPreference.Find(p => p.PickupLocationID == deliveryOptionID); if (vPickupLocation != null) { int PickupLocationID = vPickupLocation.PickupLocationID; request.ID = PickupLocationID; PickupAlternativesResponse_V01 pickupAlternativesResponse = proxy.GetPickupAlternativeForDeliveryOptionID(new GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as PickupAlternativesResponse_V01; if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null && pickupAlternativesResponse.PickupAlternatives.Count > 0) { deliveryOption = new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(pickupAlternativesResponse.PickupAlternatives[0])); deliveryOption.Id = deliveryOption.ID = PickupLocationID; return(new ShippingInfo(deliveryOption)); } } } } else { ShippingAddress_V02 shippingAddress = null; if (shippingAddressID != 0) { List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale); if (shippingAddresses != null) { if ((shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID)) == null) { shippingAddress = shippingAddresses.Find(s => s.IsPrimary == true); } } } else { List <DeliveryOption> addresses = base.GetShippingAddresses(distributorID, locale); if (addresses != null && addresses.Count > 0) { if ((shippingAddress = addresses.Find(s => s.IsPrimary == true)) == null) { shippingAddress = addresses.First(); } } } if (shippingAddress != null) { List <DeliveryOption> deliveryOptions = GetDeliveryOptions(type, shippingAddress); if (deliveryOptions != null && deliveryOptions.Count > 0) { deliveryOption = deliveryOptions.First(); return(new ShippingInfo(deliveryOption, shippingAddress)); } } } return(null); }
public override ShippingInfo GetShippingInfoFromID(string distributorID, string locale, DeliveryOptionType type, int deliveryOptionID, int shippingAddressID) { if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.UseXHLTables) { var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); var request = new ServiceProvider.ShippingMexicoSvc.DeliveryOptionForIDRequest_V01(); request.ID = deliveryOptionID; request.Country = "AR"; DeliveryOption deliveryOption = null; if (type == DeliveryOptionType.Pickup) { string countryCode = locale.Substring(3, 2); List <PickupLocationPreference_V01> pickupLocationPreference = GetPickupLocationsPreferences(distributorID, countryCode); if (pickupLocationPreference != null && pickupLocationPreference.Count > 0) { var vPickupLocation = pickupLocationPreference.Find(p => p.PickupLocationID == deliveryOptionID); if (vPickupLocation != null) { int PickupLocationID = vPickupLocation.PickupLocationID; request.ID = PickupLocationID; var pickupAlternativesResponse = proxy.GetPickupAlternativeForDeliveryOptionID(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativeForDeliveryOptionIDRequest(request)).GetPickupAlternativeForDeliveryOptionIDResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01; if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null && pickupAlternativesResponse.PickupAlternatives.Count > 0) { deliveryOption = new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(pickupAlternativesResponse.PickupAlternatives[0])); deliveryOption.Id = deliveryOption.ID = PickupLocationID; deliveryOption.Description = deliveryOption.Description; var shippingInfo = new ShippingInfo(deliveryOption); shippingInfo.Address.Address.Line1 = shippingInfo.Address.Address.Line2; shippingInfo.Address.Address.Line2 = string.Empty; return(shippingInfo); } } } } else { ShippingAddress_V02 shippingAddress = null; if (shippingAddressID != 0) { List <DeliveryOption> shippingAddresses = GetShippingAddresses(distributorID, locale); if (shippingAddresses != null) { if ((shippingAddress = shippingAddresses.Find(s => s.ID == shippingAddressID)) == null) { shippingAddress = shippingAddresses.Find(s => s.IsPrimary == true); } } } else { List <DeliveryOption> addresses = base.GetShippingAddresses(distributorID, locale); if (addresses != null && addresses.Count > 0) { if ((shippingAddress = addresses.Find(s => s.IsPrimary == true)) == null) { shippingAddress = addresses.First(); } } } if (shippingAddress != null) { List <DeliveryOption> deliveryOptions = GetDeliveryOptions(type, shippingAddress); if (deliveryOptions != null && deliveryOptions.Count > 0) { deliveryOption = deliveryOptions.First(); return(new ShippingInfo(deliveryOption, shippingAddress)); } } } return(null); } else { return(GetShippingInfoFromID(distributorID, locale, type, deliveryOptionID, shippingAddressID)); } }
public override List <DeliveryOption> GetDeliveryOptions(DeliveryOptionType type, MyHerbalife3.Ordering.ServiceProvider.ShippingSvc.ShippingAddress_V01 address) { if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.UseXHLTables) { List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetMexicoShippingServiceProxy(); if (type == DeliveryOptionType.Pickup) { var pickupAlternativesResponse = new ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01(); if (address == null || address.Address == null) { // Get Herbalife Centers - FreightCode: PU pickupAlternativesResponse = proxy.GetPickupAlternativesByFreightCode(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativesByFreightCodeRequest(new ServiceProvider.ShippingMexicoSvc.PickupAlternativesByFreightCodeRequest_V01() { Country = "AR", FreightCode = "PU" })).GetPickupAlternativesByFreightCodeResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01; } else if (!string.IsNullOrEmpty(address.Address.PostalCode)) { pickupAlternativesResponse = proxy.GetPickupAlternativesForPostalCode(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativesForPostalCodeRequest(new ServiceProvider.ShippingMexicoSvc.PickupAlternativesForPostalCodeRequest_V01() { Country = "AR", PostalCode = address.Address.PostalCode })).GetPickupAlternativesForPostalCodeResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01; } else { pickupAlternativesResponse = proxy.GetPickupAlternativesForColony(new ServiceProvider.ShippingMexicoSvc.GetPickupAlternativesForColonyRequest(new ServiceProvider.ShippingMexicoSvc.PickupAlternativesForColonyRequest_V01() { Country = "AR", Colony = address.Address.Line3, Municipality = address.Address.City, State = address.Address.StateProvinceTerritory })).GetPickupAlternativesForColonyResult as ServiceProvider.ShippingMexicoSvc.PickupAlternativesResponse_V01; } if (pickupAlternativesResponse != null && pickupAlternativesResponse.PickupAlternatives != null) { deliveryOptions.AddRange( from po in pickupAlternativesResponse.PickupAlternatives select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(po))); } } else { if (!string.IsNullOrEmpty(address.Address.PostalCode)) { var shippingAlternativesResponse = proxy.GetShippingAlternativesForPostalCode(new ServiceProvider.ShippingMexicoSvc.GetShippingAlternativesForPostalCodeRequest(new ServiceProvider.ShippingMexicoSvc.ShippingAlternativesForPostalCodeRequest_V01() { Country = "AR", PostalCode = address.Address.PostalCode })).GetShippingAlternativesForPostalCodeResult as MyHerbalife3.Ordering.ServiceProvider.ShippingMexicoSvc.ShippingAlternativesResponse_V01; if (shippingAlternativesResponse != null && shippingAlternativesResponse.DeliveryAlternatives != null) { deliveryOptions.AddRange(from so in shippingAlternativesResponse.DeliveryAlternatives where !so.ShippingSource.Status.ToUpper().Equals("NOGDO") && !so.ShippingSource.Status.ToUpper().Equals("NODISPONIBLE") select new DeliveryOption(ObjectMappingHelper.Instance.GetToShipping(so))); } } } deliveryOptions.ForEach(o => o.Address = validateAdressValues(o.Address)); return(deliveryOptions); } else { return(base.GetDeliveryOptions(type, address)); } }