public virtual List <string> GetCitiesForState(string country, string state)
 {
     try
     {
         var proxy   = ServiceClientProvider.GetShippingServiceProxy();
         var request = new CitiesForStateRequest_V01();
         request.Country = country;
         request.State   = state;
         var response = proxy.GetCitiesForState(new GetCitiesForStateRequest(request));
         var result   = response.GetCitiesForStateResult as CitiesForStateResponse_V01;
         return(result.Cities);
     }
     catch (Exception ex)
     {
         LoggerHelper.Error(string.Format("GetCitiesForState error: Country {0}, error: {1}", country,
                                          ex.ToString()));
     }
     return(null);
 }
        public List <string> GetSuburbsForCity(string country, string city)
        {
            try
            {
                string    CacheKey = string.Format("{0}{1}", "SUBURBSFORCITY_HU_", city);
                const int SUBURBSFORCITY_HU_CACHE_MINUTES = 60;

                List <string> lsSuburbsForCity = HttpRuntime.Cache[CacheKey] as List <string>;

                if (lsSuburbsForCity != null)
                {
                    return(lsSuburbsForCity);
                }
                // Using the city field from database to store the suburb/district
                var proxy   = ServiceClientProvider.GetShippingServiceProxy();
                var request = new CitiesForStateRequest_V01 {
                    Country = country, State = city
                };
                var response = proxy.GetCitiesForState(new GetCitiesForStateRequest(request)).GetCitiesForStateResult as CitiesForStateResponse_V01;

                var suburbs = new List <string>();
                if (response != null)
                {
                    suburbs = (from s in response.Cities
                               where !string.IsNullOrEmpty(s) && s.Contains("|")
                               select s.Split('|')[0]).Distinct().ToList();
                    suburbs.Sort();
                    if (suburbs.Count == 1 && string.IsNullOrEmpty(suburbs[0]))
                    {
                        suburbs.Clear();
                    }
                    HttpRuntime.Cache.Insert(CacheKey, suburbs, null, DateTime.Now.AddMinutes(SUBURBSFORCITY_HU_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                }
                return(suburbs);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("GetSuburbsForCity error: country: {0}, city: {1} error: {2}", country, city, ex));
            }
            return(null);
        }
        public List <string> GetDistrictsForCity(string country, string city, string suburb)
        {
            try
            {
                if (valueContains(suburb) || suburb.Equals(Dashes))
                {
                    suburb = string.Empty;
                }

                string    cacheKey = string.Format("{0}{1}_{2}", "DISTRICTSFORCITY_HU_", city, suburb);
                const int DISTRICTSFORCITY_HU_CACHE_MINUTES = 60;

                List <string> lsDistrictsForCity = HttpRuntime.Cache[cacheKey] as List <string>;
                if (lsDistrictsForCity != null)
                {
                    return(lsDistrictsForCity);
                }
                var districts = new List <string>();
                if (city.Equals("Budapest"))
                {
                    if (suburb == string.Empty)
                    {
                        districts = new List <string>()
                        {
                            "I.", "II.", "III.", "IV.", "V.", "VI.", "VII.", "VIII.", "IX.", "X.", "XI.", "XII.", "XIII.", "XIV.", "XV.", "XVI.", "XVII.", "XVIII.", "XIX.", "XX.", "XXI.", "XXII.", "XXIII.",
                        }
                    }
                    ;
                    if (suburb.Equals("Budafok") || suburb.Equals("Nagytétény"))
                    {
                        districts = new List <string>()
                        {
                            "XXII.",
                        }
                    }
                    ;
                    if (suburb.Equals("Helikopter-lakópark"))
                    {
                        districts = new List <string>()
                        {
                            "XVII.",
                        }
                    }
                    ;
                    if (suburb.Equals("Mátyásföld") || suburb.Equals("Sashalom"))
                    {
                        districts = new List <string>()
                        {
                            "XVI.",
                        }
                    }
                    ;
                    if (suburb.Equals("Pestszentimre") || suburb.Equals("Pestszentlőrinc"))
                    {
                        districts = new List <string>()
                        {
                            "XVIII.",
                        }
                    }
                    ;
                    return(districts);
                }
                // Using the city field from database to store the suburb/district
                var proxy   = ServiceClientProvider.GetShippingServiceProxy();
                var request = new CitiesForStateRequest_V01 {
                    Country = country, State = city
                };
                var response = proxy.GetCitiesForState(new GetCitiesForStateRequest(request)).GetCitiesForStateResult as CitiesForStateResponse_V01;

                if (response != null)
                {
                    districts = (from s in response.Cities
                                 where !string.IsNullOrEmpty(s) && s.StartsWith(string.Format("{0}|", suburb)) && !string.IsNullOrEmpty(s.Split('|')[1])
                                 select s.Split('|')[1]).Distinct().ToList();
                    if (response.Cities.Contains(string.Empty))
                    {
                        districts.Add(string.Empty);
                        districts.Sort();
                    }
                    HttpRuntime.Cache.Insert(cacheKey, districts, null, DateTime.Now.AddMinutes(DISTRICTSFORCITY_HU_CACHE_MINUTES), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                }
                return(districts);
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(string.Format("GetDistrictsForCity error: country: {0}, city: {1} error: {2}", country, city, ex.ToString()));
            }
            return(null);
        }