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.Collections.Generic
Imports System.Configuration
Imports System.Xml
Imports System.Text
Imports System.Web

Partial Class TestG2B
    Inherits System.Web.UI.Page

    Private _provider As IG2BServicesProvider

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

            Me.Provider = lProvider
        End If
    End Sub

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

    Protected Sub btnAuthenticate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAuthenticate.Click
        Dim providerRequest As EntityG2BServices.G2BAuthenticateRequest
        Dim providerResponse As EntityG2BServices.G2BAuthenticateResponse

        providerRequest = New EntityG2BServices.G2BAuthenticateRequest()
        providerRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        providerResponse = Me.Provider.Authenticate(providerRequest)
    End Sub

    Protected Sub btnCancelOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancelOrder.Click
        Dim providerRequest As EntityG2BServices.G2BCancelOrderRequest
        Dim providerResponse As EntityG2BServices.G2BCancelOrderResponse

        providerRequest = New EntityG2BServices.G2BCancelOrderRequest()
        providerRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))

        providerResponse = Me.Provider.CancelOrder(providerRequest)
    End Sub

    Protected Sub btnQueryOffers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnQueryOffers.Click
        Dim providerRequest As EntityG2BServices.G2BQueryOffersRequest
        Dim providerResponse As EntityG2BServices.G2BQueryOffersResponse

        Dim addr As New Address()
        addr.City = "FENTON"
        addr.State = "MO"
        addr.Street1 = "1701 FAITH CT"
        addr.Zip = "63026"
        addr.Zip4 = "6601"

        providerRequest = New EntityG2BServices.G2BQueryOffersRequest(addr, Nothing, 118700)
        providerRequest.SourceIPAddress = IIf(Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, Request.ServerVariables("REMOTE_ADDR"))
        providerRequest.BillingStationID = 560
        providerRequest.FTA = "0250"

        providerResponse = Me.Provider.QueryOffers(providerRequest)
    End Sub

    Protected Sub btnQueryOffersResubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnQueryOffersResubmit.Click
        Dim providerRequest As EntityG2BServices.G2BQueryOffersResubmitRequest
        Dim providerResponse As EntityG2BServices.G2BQueryOffersResubmitResponse

        providerRequest = New EntityG2BServices.G2BQueryOffersResubmitRequest(1, 1, 1, 1)
        providerRequest.SourceIPAddress = CType(IIf(System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")), String)

        providerResponse = Me.Provider.QueryOffersResubmit(providerRequest)
    End Sub

    Protected Sub btnSubmitOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmitOrder.Click
        Dim providerRequest As EntityG2BServices.G2BSubmitOrderRequest
        Dim providerResponse As EntityG2BServices.G2BSubmitOrderResponse

        Dim offers As New List(Of EntityG2BServices.OfferOrderTypeG2BOrder)

        providerRequest = New EntityG2BServices.G2BSubmitOrderRequest(offers, "TestFirstName", "TestLastName", "555-555-5555", "555-555-5555", "someone@abc.com", Nothing, Nothing, New Address(), Nothing, 1, 1, 1, 0, False, New List(Of EntityG2BServices.CustomerHardwareType))
        providerRequest.SourceIPAddress = CType(IIf(System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")), String)

        providerResponse = Me.Provider.SubmitOrder(providerRequest)
    End Sub

    Protected Sub btnScheduleInstall_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScheduleInstall.Click
        Dim providerRequest As EntityG2BServices.G2BScheduleInstallRequest
        Dim providerResponse As EntityG2BServices.G2BScheduleInstallResponse

        Dim offers As New List(Of EntityG2BServices.OfferOrderTypeG2BScheduleInstall)

        providerRequest = New EntityG2BServices.G2BScheduleInstallRequest(offers, 1, 1, 1)
        providerRequest.SourceIPAddress = CType(IIf(System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") Is Nothing, String.Empty, System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")), String)

        providerResponse = Me.Provider.ScheduleInstall(providerRequest)
    End Sub
End Class
