예제 #1
0
        private Location GetLocationByAddress(string street1, string street2, string city, string state, string postalCode)
        {
            StringBuilder filterBuilder = new StringBuilder();

            filterBuilder.AppendFormat( "Street1 eq '{0}'", street1 );

            if ( String.IsNullOrWhiteSpace( street2 ) )
            {
                filterBuilder.Append( " and ( Street2 eq null or Street2 eq '')" );

            }
            else
            {
                filterBuilder.AppendFormat( " and Street2 eq '{0}'", street2 );
            }

            filterBuilder.AppendFormat( " and City eq '{0}'", city );
            filterBuilder.AppendFormat( " and State eq '{0}'", state );
            filterBuilder.AppendFormat( " and PostalCode eq '{0}'", postalCode );

            LocationController controller = new LocationController( Service );
            return controller.GetByFilter( filterBuilder.ToString() ).FirstOrDefault();
        }