
Imports EBSServicesProvider
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports System.Xml


Partial Class TestServiceability
    Inherits System.Web.UI.Page


    Private _provider As IEBSServicesProvider


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            Dim lProvider As New EBSServicesProvider.ProviderManager
            Me.Provider = lProvider
        End If
    End Sub

    Private Property Provider() As IEBSServicesProvider
        Get
            Return _provider
        End Get
        Set(ByVal value As IEBSServicesProvider)
            _provider = value
        End Set
    End Property

    Protected Sub btnServiceabilityByAddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnServiceabilityByAddress.Click
        Try
            Dim objRequest As New GetServiceabilityRequest
            Dim objResponse As New GetServiceabilityResponse

            Dim lCriteria As New ServiceabilityCriteria
            Dim lAddress As New ServiceabilityCriteriaAddress
            lAddress.AddressLine1 = "926 S. Grape"
            lAddress.AddressLine2 = ""
            lAddress.CleansedAddress = True
            lAddress.ZipCode = "97501"

            lAddress.ZipCode4 = ""

            lCriteria.Item = lAddress
            lCriteria.ItemElementName = ItemChoiceType.Address

            objRequest.Criteria = lCriteria
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))


            objResponse = Me.Provider.GetServiceability(objRequest)

            If Not (objResponse Is Nothing) Then
                If Not objResponse.ExceptionMessage Is Nothing Then
                    '##########################
                    'ws exception has occured.
                    '##########################
                    Response.Write(objResponse.ExceptionMessage)
                Else
                    If Not (objResponse.ServiceabilityResult Is Nothing) Then
                        '###################################
                        'Serviceability looks to be good.
                        '###################################
                        'If Not objResponse.ServiceabilityResult.LocationAvailableServices Is Nothing Then
                        Response.Write("Serviceability Test is Good") ' & objResponse.ServiceabilityResult.LocationAvailableServices.FTA)
                        'Else
                        '    Response.Write("Serviceability result and Location Available services result is Nothing")
                        'End If
                    Else
                        Response.Write("ServiceabilityResult came back as Nothing")
                    End If
                End If
            Else
                Response.Write("objResponse came back as Nothing")
            End If

        Catch ex As Exception
            Response.Write("Serviceability  Failed with the following error....    ")
            Response.Write(ex.Message)
        End Try
    End Sub
End Class
