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); }
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); }