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); }
public List <DeliveryOption> GetDeliveryOptionForDistributor(string distributorId, DeliveryOptionType type) { var deliveryOptions = new List <DeliveryOption>(); if (type == DeliveryOptionType.PickupFromCourier) { var cacheKey = GetFedexCacheKey(); var locations = HttpRuntime.Cache[cacheKey] as Dictionary <string, List <DeliveryOption> >; if (locations == null || !locations.ContainsKey(distributorId)) { if (locations == null) { locations = new Dictionary <string, List <DeliveryOption> >(); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); try { var pickupAlternativesResponse = proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V05() { CountryCode = "CA", DistributorId = distributorId })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V05; if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null) { deliveryOptions.AddRange(from po in pickupAlternativesResponse.DeliveryPickupAlternatives select new DeliveryOption(po, true)); deliveryOptions.ForEach(po => { po.DisplayName = string.Format("{0} #{1}", FedExNickName, po.CourierStoreId); po.GeographicPoint = po.GeographicPoint.Replace("/", string.Empty); po.Information = FormatAdditionalInfo(po.Information); po.Description = po.Name; }); } if (deliveryOptions.Any()) { locations.Add(distributorId, deliveryOptions); HttpRuntime.Cache.Insert(cacheKey, locations, null, DateTime.Now.AddMinutes(FedexCacheMinutes), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } catch (Exception ex) { LoggerHelper.Error( string.Format("GetDeliveryOptionForDistributor error: Country: CA, error: {0}", ex.Message)); } } if (locations.ContainsKey(distributorId)) { var locList = locations.FirstOrDefault(l => l.Key == distributorId); deliveryOptions = locList.Value; } } return(deliveryOptions); }
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) { List <DeliveryOption> result = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetShippingServiceProxy(); DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01(); request.Country = Country; //request.State = request.State = (address != null && address.Address != null && !string.IsNullOrEmpty(address.Address.StateProvinceTerritory)) ? address.Address.StateProvinceTerritory : "HK"; 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; result.Add(currentOption); } return(result.OrderBy(d => d.displayIndex.ToString() + "_" + d.DisplayName).ToList()); }
public override List <string> GetZipsForStreet(string country, string city, string suburb, string street) { try { string CacheKey = string.Format("{0}{1}_{2}_{3}", "ZIPCODE_HU_", city, suburb, street); const int ZIPCODE_HU_CACHE_MINUTES = 60; var zips = HttpRuntime.Cache[CacheKey] as List <string>; if (zips != null) { return(zips); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new ZipsForStreetRequest_V01(); request.Country = country; request.State = city; request.City = suburb; request.Street = street; var response = proxy.GetZipsForStreet(new GetZipsForStreetRequest(request)).GetZipsForStreetResult as ZipsForStreetResponse_V01; if (response != null && response.Zips != null) { HttpRuntime.Cache.Insert(CacheKey, response.Zips, null, DateTime.Now.AddMinutes(ZIPCODE_HU_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } return(response.Zips); } catch (Exception ex) { LoggerHelper.Error( string.Format("GetZipsForStreet error: Country {0}, error: {1}", country, ex)); } return(null); }
private static List <DeliveryOption> GetDeliveryOptionsByStateFromService(string Country, string locale, ShippingAddress_V01 address, DeliveryOptionType type) { if (address == null || address.Address == null || string.IsNullOrEmpty(address.Address.StateProvinceTerritory)) { return(null); } DeliveryPickupAlternativesResponse_V05 pickupAlternativesResponse = null; if (type == DeliveryOptionType.PickupFromCourier) { List <DeliveryOption> result = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetShippingServiceProxy(); pickupAlternativesResponse = proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V05 { CountryCode = Country, State = address.Address.StateProvinceTerritory })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V05; if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null) { pickupAlternativesResponse.DeliveryPickupAlternatives.ForEach(d => { d.Description = d.CourierAddress; d.CourierName = d.ID.ToString(); }); result.AddRange( from po in pickupAlternativesResponse.DeliveryPickupAlternatives orderby po.ID select new DeliveryOption(po as DeliveryPickupOption_V03, true)); Array.ForEach(result.ToArray(), a => { a.Address = getAddress(a.Name, a.State, a.PostalCode); a.Address.CountyDistrict = string.Format("відділення МІСТ № {0}", a.Id.ToString()); }); } return(result); } return(null); }
public override bool ValidatePostalCode(string country, string state, string city, string postalCode) { bool isValid = false; //if(!string.IsNullOrEmpty(postalCode)) //{ // postalCode = postalCode.Split(' ')[0]; //} using (var client = ServiceClientProvider.GetShippingServiceProxy()) { var requestV01 = new ValidatePostalCodeRequest_V01 { City = city, Country = country, State = state, PostalCode = postalCode }; var responseV01 = client.ValidatePostalCode(new ValidatePostalCodeRequest(requestV01)).ValidatePostalCodeResult as ValidatePostalCodeResponse_V01; if (null != responseV01 && responseV01.Status == ServiceResponseStatusType.Success) { isValid = responseV01.IsValidPostalCode; } } //ZipCode Whitespace rule enforcement int whiteSpaceMatchCount = postalCode.Split(new[] { ' ' }).Length - 1; if (whiteSpaceMatchCount > 1) { isValid = false; } return(isValid); }
/// <summary> /// Gets a list of street types for a locality. /// </summary> /// <param name="country">Country code.</param> /// <param name="city">City name.</param> /// <param name="locality">Locality name.</param> /// <returns>List of street types.</returns> public List <string> GetStreetTypeForCity(string country, string city, string locality) { try { var proxy = ServiceClientProvider.GetShippingServiceProxy(); StreetsForCityRequest_V01 request = new StreetsForCityRequest_V01(); request.Country = country; request.State = city; request.City = locality; StreetsForCityResponse_V01 response = proxy.GetStreetsForCity(new GetStreetsForCityRequest(request)).GetStreetsForCityResult as StreetsForCityResponse_V01; List <string> streetTypes = new List <string>(); foreach (var street in response.Streets) { var info = street.Split('|'); if (info.Length == 2 && !streetTypes.Contains(info[0])) { streetTypes.Add(info[0]); } } return(streetTypes); } catch (Exception ex) { LoggerHelper.Error(string.Format("GetStreetTypeForCity error: Country {0}, error: {1}", country, ex.ToString())); } return(null); }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country, string locale, ShippingAddress_V01 address) { var deliveryOptions = HttpRuntime.Cache[ShippingOptionsCacheKey] as List <DeliveryOption>; if (deliveryOptions == null || deliveryOptions.Count == 0) { if (deliveryOptions == null) { deliveryOptions = new List <DeliveryOption>(); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01 { Country = Country, State = "*", Locale = locale }; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; if (response != null && response.DeliveryAlternatives != null) { deliveryOptions.AddRange(response.DeliveryAlternatives.Select(option => new DeliveryOption(option))); } if (deliveryOptions.Any()) { HttpRuntime.Cache.Insert(ShippingOptionsCacheKey, deliveryOptions, null, DateTime.Now.AddMinutes(ShippingOptionsCacheMinutes), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } return(deliveryOptions); }
public override int SavePickupLocation(InsertCourierLookupRequest_V01 request) { var retValue = 0; if (request != null || request.CourierStoreNumber > 0 || !string.IsNullOrEmpty(request.CountryCode)) { try { // Call the Shipping service to Insert a new Pickup location var service = ServiceClientProvider.GetShippingServiceProxy(); var response = service.InsertCourierLookup(new InsertCourierLookupRequest1(request)).InsertCourierLookupResult as InsertCourierLookupResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { return(response.ID); } } catch (Exception ex) { LoggerHelper.Error(string.Format("SavePickupLocation error: Country {0}, CourierStoreNumber {1}, error: {2}", request.CountryCode, request.CourierStoreNumber, ex.ToString())); } } return(retValue); }
public override bool UpdatePrimaryPickupLocationPreference(int pickupLocationId) { if (pickupLocationId == 0) { return(false); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); try { ; var response = proxy.UpdatePickupLocationPreferences(new UpdatePickupLocationPreferencesRequest1( new UpdatePickupLocationPreferencesRequest_V01() { ID = pickupLocationId })).UpdatePickupLocationPreferencesResult as UpdatePickupLocationPreferencesResponse_V01; if (response != null && response.Status == ServiceResponseStatusType.Success) { return(pickupLocationId == response.ID); } } catch (Exception ex) { LoggerHelper.Error( string.Format("UpdatePrimaryPickupLocationPreference error: Country: TH, error: {0}", ex.Message)); return(false); } return(true); }
private Dictionary <int, string> GetTaxAreaIdFromService(string memberId, DateTime current, int daysToPurge) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new GetTaxAreaIdListRequest_V01 { Current = current, DaysToPurge = daysToPurge, MemberId = memberId }; try { var response = proxy.GetTaxAreaIdList(new GetTaxAreaIdListRequest1(request)).GetTaxAreaIdListResult; if (null != response && response.Status == ServiceResponseStatusType.Success) { var responseV01 = response as GetTaxAreaIdListResponse_V01; if (null != responseV01) { return(responseV01.TaxAreaIds); } } } catch (Exception ex) { LoggerHelper.Exception("System.Exception", ex, "Error occured while getting TaxAreaId for " + memberId); } finally { proxy.Close(); } return(null); }
public List <AddressData_V02> GetAddressData(string searchTerm) { var addressesFound = new List <AddressData_V02>(); try { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new SearchAddressDataRequest_V01 { SearchText = searchTerm }; var response = proxy.GetAddressData(new GetAddressDataRequest(request)); if (response != null) { var result = response.GetAddressDataResult as SearchAddressDataResponse_V01; if (result.Status == ServiceResponseStatusType.Success) { if (result.AddressData != null && result.AddressData.Count > 0) { addressesFound.AddRange(result.AddressData); } } return(addressesFound); } } catch (Exception ex) { LoggerHelper.Error(string.Format("AddressSearch error: Country {0}, error: {1}", "BR", ex)); } return(addressesFound); }
/// <summary> /// Retrieves FreightCode and WareHouse from mappings defined in dbo.LuShippingFreightCode table. /// Combines STATE|CITY|COUNTY to search for a matching FreightCode and WareHouse in DB. /// </summary> /// <param name="a">The address used as input for mapping lookup</param> /// <returns></returns> private static string[] GetFreightCodeAndWarehouseFromService(ShippingAddress_V01 a) { var request = new DeliveryOptionForCountryRequest_V01 { Country = "PA", State = string.Format("{0}|{1}|{2}", a.Address.StateProvinceTerritory, a.Address.City, a.Address.CountyDistrict), Locale = "es-PA" }; using (var proxy = ServiceClientProvider.GetShippingServiceProxy()) { try { var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; if (response != null && response.DeliveryAlternatives != null && response.DeliveryAlternatives.Count > 0) { var shippingOption = response.DeliveryAlternatives.FirstOrDefault(); if (shippingOption != null) { return(new[] { shippingOption.FreightCode, shippingOption.WarehouseCode }); } } } catch (Exception ex) { LoggerHelper.Error(string.Format("GetFreightCodeAndWarehouseFromService error: Country: GT, error: {0}", ex.ToString())); } } return(null); }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string Country, string locale, ShippingAddress_V01 address) { var final = new List <DeliveryOption>(); if (HLConfigManager.Configurations.DOConfiguration.AllowHAP && OrderType.ToString().Equals("HSO")) { final.Add(new DeliveryOption( new ShippingOption_V01(HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultFreightCodeForHAP, "FedEx", DateTime.MinValue, DateTime.MaxValue))); return(final); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01(); request.Country = Country; request.State = address.Address.StateProvinceTerritory.Trim(); request.Locale = locale; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; foreach (ShippingOption_V01 option in response.DeliveryAlternatives) { final.Add(new DeliveryOption(option)); } return(final); }
public virtual List <AddressFieldInfo> GetAddressFieldsForCountry(AddressFieldForCountryRequest_V01 request) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var response = proxy.GetAddressFieldForCounty(new GetAddressFieldForCountyRequest(request)); var result = response.GetAddressFieldForCountyResult as AddressFieldForCountryResponse_V01; return(result.AddressInfoList); }
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()); } }
public virtual List <string> GetStatesForCountry(string country) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new StatesForCountryRequest_V01(); request.Country = country; var response = proxy.GetStatesForCountry(new GetStatesForCountryRequest(request)); var result = response.GetStatesForCountryResult as StatesForCountryResponse_V01; return(result.States); }
public override List <string> GetStatesForCountry(string Country) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new StatesForCountryRequest_V02() { Country = Country, UseCourierTable = true }; var response = proxy.GetStatesForCountry(new GetStatesForCountryRequest(request)).GetStatesForCountryResult as StatesForCountryResponse_V01; return(response.States); }
private DeliveryOption GetDeliveryOptionsListForShippingFromService(ShippingAddress_V01 address) { if (address != null && address.Address != null && !string.IsNullOrEmpty(address.Address.StateProvinceTerritory) && !string.IsNullOrEmpty(address.Address.City)) { var cityState = IsValidShippingAddress(address.Address) ? string.Format("{0}|{1}|{2}", address.Address.StateProvinceTerritory, address.Address.City, address.Address.Line4) : string.Format("{0}|{1}|{2}|{3}", address.Address.StateProvinceTerritory, address.Address.CountyDistrict, address.Address.Line3, address.Address.Line4); var options = HttpRuntime.Cache[CacheKey] as Dictionary <string, DeliveryOption>; if (options == null || !options.ContainsKey(cityState)) { using (var proxy = ServiceClientProvider.GetShippingServiceProxy()) { try { var request = new DeliveryOptionForCountryRequest_V01 { Country = "GT", State = cityState, Locale = "es-GT" }; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; if (response != null && response.DeliveryAlternatives != null && response.DeliveryAlternatives.Count > 0) { var shippingOption = response.DeliveryAlternatives.FirstOrDefault(); if (shippingOption != null) { if (options == null) { options = new Dictionary <string, DeliveryOption>(); } options.Add(cityState, new DeliveryOption(shippingOption)); HttpRuntime.Cache.Insert(CacheKey, options, null, DateTime.Now.AddMinutes(GT_DELIVERYINFO_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } } catch (Exception ex) { LoggerHelper.Error(string.Format("GetDeliveryOptionsListForShippingFromService error: Country: GT, error: {0}", ex.ToString())); } } } if (options != null && options.ContainsKey(cityState)) { var deliveryOption = options.FirstOrDefault(o => o.Key == cityState); return(deliveryOption.Value); } } return(null); }
public List <string> GetStreetType(string country, string city, string suburb, string district, string street) { try { // Using the street field from database to store the street name/street type if (valueContains(suburb) || suburb.Equals(Dashes)) { suburb = string.Empty; } if (valueContains(district)) { district = string.Empty; } string CacheKey = string.Format("{0}{1}_{2}_{3}_{4}", "STREETTYPE_HU_", city, suburb, district, street); const int STREETTYPE_HU_CACHE_MINUTES = 60; var types = HttpRuntime.Cache[CacheKey] as List <string>; if (types != null) { return(types); } var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new StreetsForCityRequest_V01 { Country = country, State = city, City = string.Format("{0}|{1}", suburb, district) }; var response = proxy.GetStreetsForCity(new GetStreetsForCityRequest(request)).GetStreetsForCityResult as StreetsForCityResponse_V01; if (response != null) { types = (from s in response.Streets where !string.IsNullOrEmpty(s) && s.StartsWith(string.Format("{0}|", street)) select s.Split('|')[1]).Distinct().Where(s => !string.IsNullOrEmpty(s)).ToList(); if (response.Streets.Contains("^")) { types.Add("^"); types.Sort(); } HttpRuntime.Cache.Insert(CacheKey, types, null, DateTime.Now.AddMinutes(STREETTYPE_HU_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } return(types); } catch (Exception ex) { LoggerHelper.Error(string.Format("GetStreetType error: country: {0}, city: {1} error: {2}", country, city, ex.ToString())); } return(null); }
private static List <ShippingOption_V01> GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address) { var final = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01(); request.Country = Country; request.State = string.IsNullOrWhiteSpace(address.Address.CountyDistrict) ? string.Format("{0}|{1}", address.Address.StateProvinceTerritory, address.Address.City) : string.Format("{0}|{1}|{2}", address.Address.StateProvinceTerritory, address.Address.City, address.Address.CountyDistrict); request.Locale = locale; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; return(response.DeliveryAlternatives); }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country, string locale, ShippingAddress_V01 address) { var final = new List <DeliveryOption>(); if (!String.IsNullOrEmpty(address.Address.PostalCode)) { int postalCodeIntValue = 0; bool validCode = int.TryParse(address.Address.PostalCode.Split('-')[0], out postalCodeIntValue); if (validCode) { var deliveryOptionList = GetDeliveryOptionsListForShipping(locale); if (deliveryOptionList.Count > 0) { foreach (var option in deliveryOptionList) { var minRange = 0; var maxRange = 0; var range = option.PostalCode.Split('-'); if (range.Count() == 2 && int.TryParse(range[0], out minRange) && int.TryParse(range[1], out maxRange)) { if (postalCodeIntValue >= minRange && postalCodeIntValue <= maxRange) { final.Add(option); } } } } if (final.Count == 0) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); DeliveryOptionForCountryRequest_V01 request = new DeliveryOptionForCountryRequest_V01(); request.Country = country; request.State = String.Empty; request.Locale = locale; ShippingAlternativesResponse_V01 response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; foreach (ShippingOption_V01 option in response.DeliveryAlternatives) { final.Add(new DeliveryOption(option)); } } } } return(final); }
private static List <DeliveryOption> GetDeliveryOptionsFromService(string country, string locale, ShippingAddress_V01 address) { List <DeliveryOption> deliveryOptions = new List <DeliveryOption>(); CityBoxAlternativesResponse_V01 response = null; var proxy = ServiceClientProvider.GetShippingServiceProxy(); response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(new GetCityBoxRequest_V01() { Country = "CL", FreightCode = FreightCode_CityBox, Warehouse = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse.ToString(), Locale = "es-CL" })).GetDeliveryOptionsResult as CityBoxAlternativesResponse_V01; DeliveryOption dlv; Address_V01 add; if (response != null && response.DeliveryAlternatives != null) { foreach (var location in response.DeliveryAlternatives) { add = new Address_V01() { City = location.City, Country = location.Country, CountyDistrict = location.CountyDistrict, Line1 = location.LocationDescription, Line2 = "", Line3 = location.Line1, Line4 = location.Line2, PostalCode = location.PostalCode, StateProvinceTerritory = location.StateProvinceTerritory }; int id = location.ID; dlv = new DeliveryOption(new ShippingAddress_V02() { ID = id, Recipient = location.LocationDescription, FirstName = string.Empty, LastName = string.Empty, MiddleName = string.Empty, Address = add, Phone = "", AltPhone = "", IsPrimary = false, Alias = location.LocationDescription, Created = DateTime.Now }); dlv.WarehouseCode = HLConfigManager.Configurations.ShoppingCartConfiguration.DefaultWarehouse; dlv.FreightCode = FreightCode_CityBox; deliveryOptions.Add(dlv); } } return(deliveryOptions); }
private static List <DeliveryOption> GetDeliveryOptionsFromService(string locale) { var deliveryOptions = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetShippingServiceProxy(); DeliveryPickupAlternativesResponse_V04 pickupAlternativesResponse = null; pickupAlternativesResponse = proxy.GetDeliveryPickupAlternatives(new GetDeliveryPickupAlternativesRequest(new DeliveryPickupAlternativesRequest_V04 { Locale = locale })).GetDeliveryPickupAlternativesResult as DeliveryPickupAlternativesResponse_V04; if (pickupAlternativesResponse != null && pickupAlternativesResponse.DeliveryPickupAlternatives != null) { deliveryOptions.AddRange( from po in pickupAlternativesResponse.DeliveryPickupAlternatives select new DeliveryOption(po, true)); } return(deliveryOptions); }
private static string[] GetFreightCodeAndWarehouseFromService(ShippingAddress_V01 address) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01 { Country = "AR", Locale = "es-AR", State = string.Format("{0}-{1}", address.Address.StateProvinceTerritory, address.Address.PostalCode) }; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; var shippingOption = response.DeliveryAlternatives.FirstOrDefault(); if (shippingOption != null) { return(new[] { shippingOption.FreightCode, shippingOption.WarehouseCode }); } return(null); }
private string[] GetFreightCodeAndWarehouseFromService(string state) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01 { Country = "TH", Locale = "th-TH", State = state }; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; var shippingOption = response.DeliveryAlternatives.FirstOrDefault(); if (shippingOption != null) { return(new[] { shippingOption.FreightCode, shippingOption.WarehouseCode }); } return(null); }
public virtual List <StateCityLookup_V01> LookupCitiesByZip(string country, string zipcode) { try { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new StateAndCityByZipLookupRequest_V01(); request.Country = country; request.ZipCode = zipcode; var response = proxy.GetStateAndCityForZipCode(new GetStateAndCityForZipCodeRequest(request)); var result = response.GetStateAndCityForZipCodeResult as StateAndCityByZipLookupResponse_V01; return(result.StateCities); } catch (Exception ex) { LoggerHelper.Error(string.Format("LookupCitiesByZip error: Country {0}, error: {1}", country, ex.ToString())); } return(null); }
public override List <DeliveryOption> GetDeliveryOptionsListForShipping(string country, string locale, ShippingAddress_V01 address) { var final = new List <DeliveryOption>(); var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01(); request.Country = country; request.State = String.Empty; request.Locale = locale; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; foreach (ShippingOption_V01 option in response.DeliveryAlternatives) { final.Add(new DeliveryOption(option)); } return(final); }
private ShippingAlternativesResponse_V01 GetDeliveryOptionsFromService(string Country, string locale, ShippingAddress_V01 address) { var proxy = ServiceClientProvider.GetShippingServiceProxy(); var request = new DeliveryOptionForCountryRequest_V01(); request.Country = Country; request.State = address.Address.PostalCode.Substring(0, 2); request.Locale = locale; var response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; if (response.DeliveryAlternatives.Count == 0) { request.State = "*"; response = proxy.GetDeliveryOptions(new GetDeliveryOptionsRequest(request)).GetDeliveryOptionsResult as ShippingAlternativesResponse_V01; } return(response); }