Example #1
0
        private void GetZipCodeInfoButton_Click(object sender, RoutedEventArgs e)
        {
            CityOutputTextBox.Text    = "";
            StateOutputTextBox.Text   = "";
            ErrorMessage1TextBox.Text = "";
            string zipCode = ZipCodeTextBox.Text;

            // ReSharper disable once InvertIf
            if (zipCode != "")
            {
                WcfBindingType wcfBindingType = GetBindingTypeFromRadioButtons();
                GeoClient      geoClient      = GetGeoClientWithBinding(wcfBindingType);
                ZipCodeData    zipCodeData    = null;

                try
                {
                    zipCodeData = geoClient.GetZipCodeInfo(zipCode);
                }
                catch (FaultException exception)
                {
                    string message = "Exception: \r\n" +
                                     $"Message = {exception.Message} \r\n" +
                                     $"Proxy state = {geoClient.State.ToString()}";

                    CityOutputTextBox.Text    = "";
                    StateOutputTextBox.Text   = "";
                    ErrorMessage1TextBox.Text = message;
                }

                if (zipCodeData != null)
                {
                    CityOutputTextBox.Text  = zipCodeData.City;
                    StateOutputTextBox.Text = zipCodeData.State;
                }

                geoClient.Close();
            }
        }