Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.WebSite.Library
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.Common.Logging
Imports CheckFirmwareUpgradeEligibility

Partial Class FirmwareUpgrade_Check
    Inherits CharterCMSPage

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        SetContentKeys()
    End Sub

    Private Sub SetContentKeys()
        'Support / Overview
        'Me.litSupportOverviewHeader.Text = GetCMSContent("Support:Overview:Header")
    End Sub

    Protected Sub btnCheck_Click1(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCheck.Click
        If Page.IsValid Then
            Dim account As String
            Dim mac As String
            Dim phone As String
            Dim zip As String

            Dim eligibilityStatus As String

            account = accountNumber.Text
            mac = macAddress.Text
            phone = phoneNumber.Text
            zip = zipCode.Text

            Dim checkLegacyWIFI As ClsCheckLegacyWIFI = New ClsCheckLegacyWIFI()

            'checkLegacyWIFI.AccountNumber = "1234567890123456"
            'checkLegacyWIFI.MacAddress = "123456789012"
            'checkLegacyWIFI.PhoneNumber = "111-111-1111"
            'checkLegacyWIFI.ZipCode = "90000"

            checkLegacyWIFI.AccountNumber = account
            checkLegacyWIFI.MacAddress = mac
            checkLegacyWIFI.PhoneNumber = phone
            checkLegacyWIFI.ZipCode = zip

            eligibilityStatus = checkLegacyWIFI.checkEligibilityStatus(checkLegacyWIFI)

            If Len(eligibilityStatus) = 0 Then
                lblError.Visible = False
                Response.Redirect("FWDownload.aspx")
            Else
                lblError.Visible = True
                lblError.Text = eligibilityStatus
            End If

            Logger.WebLog("GetCMSContent")
        End If
    End Sub

    Private Function GetCMSContent(ByVal userControlName As String) As String
        Dim cmsContent As String = String.Empty

        Logger.WebLog("GetCMSContent")

        cmsContent = ContentManager.Instance.GetContent(userControlName, "1", OwnerType.Other)
        If (cmsContent Is Nothing) Then
            cmsContent = "content not found: " & userControlName
        End If
        Return cmsContent
    End Function
End Class
