Exemple #1
0
            private EntityDataServiceResponse <ZipCodeInfo> GetFromZipPostalCodes(GetFromZipPostalCodeDataRequest request)
            {
                ThrowIf.Null(request.CountryRegionCode, "countryRegionCode");
                ThrowIf.Null(request.ZipPostalCode, "zipPostalCode");

                ParameterSet filters = new ParameterSet();

                filters[AddressServiceConstants.CountryRegionId] = request.CountryRegionCode;
                filters[AddressServiceConstants.ZipCode]         = request.ZipPostalCode;

                PagedResult <ZipCodeInfo> fromZipCodes;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    fromZipCodes = sqlServerDatabaseContext.ExecuteStoredProcedure <ZipCodeInfo>(GetFromZipCodesInfoSprocName, filters);
                }

                return(new EntityDataServiceResponse <ZipCodeInfo>(fromZipCodes));
            }
            /// <summary>
            /// Gets from zip postal code.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response..</returns>
            private static GetFromZipPostalCodeServiceResponse GetFromZipPostalCode(GetFromZipPostalCodeServiceRequest request)
            {
                ValidateGetAddressInfoRequests(request);

                string countryRegionId = request.Filters[AddressServiceConstants.CountryRegionId].ToString();

                string zipCode = string.Empty;

                if (request.Filters[AddressServiceConstants.ZipCode] != null)
                {
                    zipCode = request.Filters[AddressServiceConstants.ZipCode].ToString();
                }

                var getZipcodeDataRequest = new GetFromZipPostalCodeDataRequest(countryRegionId, zipCode);

                getZipcodeDataRequest.QueryResultSettings = request.QueryResultSettings;
                var zipcodeDataSet = request.RequestContext.Runtime.Execute <EntityDataServiceResponse <ZipCodeInfo> >(getZipcodeDataRequest, request.RequestContext);

                return(new GetFromZipPostalCodeServiceResponse(zipcodeDataSet.PagedEntityCollection));
            }