Imports System.Collections.Generic
Imports CharterDotCom.CommonEntities.Library
' issue 27678
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library
Imports System.Web.Security
Imports System.Text.RegularExpressions
Imports CharterDotCom.CommonEntities.Library.EntityEBSServices

Partial Class Controls_RetrieveUsernameStep1
	Inherits System.Web.UI.UserControl
	Implements IMyAccountStepPage

	Private m_sError As String
	Dim _myQueryString As String

#Region " Properties "

	Public Property QueryKey() As String
		Get
			Return _myQueryString
		End Get
		Set(ByVal value As String)
			_myQueryString = value
		End Set
	End Property

	Public ReadOnly Property ErrorMessage() As String Implements IMyAccountStepPage.ErrorMessage
		Get
			Return m_sError
		End Get
	End Property

#End Region

#Region " Page Events "

#End Region

#Region " Subs and Functions "

	Public Function DoWork() As Boolean Implements IMyAccountStepPage.DoWork
		Dim _result As Enumerations.BLRetUsernameStatus
		Dim sPhone As String

		If txtZipCode.Text.Length = 5 Then

			sPhone = txtAreaCode.Text & txtPrefix.Text & txtExtension.Text
			Dim lAccount As IAccount = AccountManager.Instance.GetAccount()
			_result = AccountManager.Instance.GetAccountsForRetrieveUsername(txtAccountNumber.Text, sPhone, txtZipCode.Text)

			Select Case _result
				Case BLRetUsernameStatus.Mutliple
					lblMultipleAccountMessage.Visible = True
					tblPhoneNumber.Visible = False
					lblStep1Header.Text = "Step 1 - Enter Account Number"
					Return False

				Case BLRetUsernameStatus.None
					Return False

				Case BLRetUsernameStatus.Success
					Return True

				Case BLRetUsernameStatus.Error
					Select Case True

						Case Not AccountManager.Instance.GetLastCCOMDisplayFriendlyExceptionMessage Is Nothing
							m_sError = AccountManager.Instance.GetLastCCOMDisplayFriendlyExceptionMessage
							AccountManager.Instance.ClearCCOMDisplayFriendlyExceptionMessage()
						Case Else
							m_sError = "Your registration cannot be completed."
                    End Select
                    Return False
            End Select

            Return True
		Else
            m_sError = "Please supply a valid zip code."
            Return False
		End If

	End Function

#End Region

End Class