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 TESTHARNESS_TestProviders_Test_CPNIVerification
    Inherits System.Web.UI.Page

    Private _provider As IEBSServicesProvider

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

    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

    Protected Sub btnCPNIVerificationCSG_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCPNIVerificationCSG.Click

        Try
            Dim objRequest As New GetCPNIVerificationRequestCSG
            Dim objResponse As New GetCPNIVerificationResponseCSG

            objRequest.AccountNumber = txtAcctId.Text
            Dim objCsgHeaderInfo As New CsgHeaderInfo_CPNIVerification
            objCsgHeaderInfo.RoutingArea = txtAcctId.Text.Substring(0, 6) & "00"
            objRequest.CsgHeaderInfo = objCsgHeaderInfo
            objRequest.PIN = txtPin.Text
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

            objResponse = Me.Provider.GetCPNIVerificationFromCSG(objRequest)

            If Not (objResponse Is Nothing) Then
                If Not (objResponse.Exception) Then
                    If objResponse.Verified Then
                        Response.Write("CPNIVerificationCSG is <b>Good</b><br>")
                        Response.Write("<BR/>" & objResponse.Result.ToString())
                        Return
                    Else
                        Response.Write("CPNIVerificationCSG is <b>Bad</b> - Not Verified<br>")
                        Response.Write("<BR/>" & objResponse.Result.ToString())
                        Return
                    End If
                Else
                    Response.Write("CPNIVerificationCSG is <b>Bad</b> - Exception" & "<br>")
                    Response.Write("<BR/>" & objResponse.ExceptionMessage)
                    Response.Write("<BR/>" & objResponse.Result.ToString())
                    Return
                End If
            Else
                Response.Write("CPNIVerificationCSG is <b>Bad</b> - no response object" & "<br>")
                Return
            End If

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

    End Sub

    Protected Sub btnCPNIVerificationICOMS_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCPNIVerificationICOMS.Click

        Try
            Dim objRequest As New GetCPNIVerificationRequestICOMS
            Dim objResponse As New GetCPNIVerificationResponseICOMS

            objRequest.AccountNumber = txtAcctId.Text
            Dim objIcomsHeaderInfo As New IcomsHeaderInfo_CPNIVerification
            objIcomsHeaderInfo.SiteId = txtAcctId.Text.Substring(0, 3)
            objRequest.IcomsHeaderInfo = objIcomsHeaderInfo
            objRequest.PIN = txtPin.Text
            objRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

            objResponse = Me.Provider.GetCPNIVerificationFromICOMS(objRequest)

            If Not (objResponse Is Nothing) Then
                If Not (objResponse.Exception) Then
                    If objResponse.Verified Then
                        Response.Write("CPNIVerificationICOMS is <b>Good</b><br>")
                        Response.Write("<BR/>" & objResponse.Result.ToString())
                        Return
                    Else
                        Response.Write("CPNIVerificationICOMS is <b>Bad</b> - Not Verified<br>")
                        Response.Write("<BR/>" & objResponse.Result.ToString())
                        Return
                    End If
                Else
                    Response.Write("CPNIVerificationICOMS is <b>Bad</b> - Exception" & "<br>")
                    Response.Write("<BR/>" & objResponse.ExceptionMessage)
                    Response.Write("<BR/>" & objResponse.Result.ToString())
                    Return
                End If
            Else
                Response.Write("CPNIVerificationICOMS is <b>Bad</b> - no response object" & "<br>")
                Return
            End If

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

    End Sub
End Class
