Imports CharterDotCom.CommonEntities.Library.Enumerations

Public Class Common

    Delegate Sub Notify(ByVal message As INotification)

#Region "Constants"

    Public Const m_CHARTER_AFFLIATE_ID As Integer = 118700
    Public Const m_SUPPORT_CACHE As String = "SupportCache"
    Public Const m_EBASIC_SERVICEPLAN_ID As String = "5500"

    Public Const m_TOTALVIEWID As String = "TOTALVIEWID"
    Public Const m_DIGITALVIEWID As String = "DIGITALVIEWID"
    Public Const m_VIEWPRICEADJUST As String = "VIEWPRICEADJUST"


    Public Const m_CHOOSEOPTIONS_PACKAGE2_SPORTSVIEW_ID As String = "CHOOSEOPTIONS_PACKAGE2_SPORTSVIEW_ID"
    Public Const m_CHOOSEOPTIONS_PACKAGE2_LATINOVIEW_ID As String = "CHOOSEOPTIONS_PACKAGE2_LATINOVIEW_ID"
    Public Const m_CHOOSEOPTIONS_PACKAGE2_MOVIEVIEW_ID As String = "CHOOSEOPTIONS_PACKAGE2_MOVIEVIEW_ID"
    Public Const m_CHOOSEOPTIONS_PACKAGE2_CHARTERTOTALVIEW_ID As String = "CHOOSEOPTIONS_PACKAGE2_CHARTERTOTALVIEW_ID"
    Public Const m_CHOOSEOPTIONS_PACKAGE2_CHARTERDIGITALVIEW_ID As String = "CHOOSEOPTIONS_PACKAGE2_CHARTERDIGITALVIEW_ID"


#End Region

#Region "Type Conversions"

    Public Shared Function ConvertToUICategory(ByVal c As GWYCategory) As Category
        Select Case c
            Case GWYCategory.Cable
                Return Category.Cable
            Case GWYCategory.HSD
                Return Category.HSD
            Case GWYCategory.Telephoney
                Return Category.Telephoney
            Case GWYCategory.UnSpecified
                Return Category.UnSpecified
            Case Else
                Throw New ApplicationException("UnKnown Category")
        End Select
    End Function

    Public Shared Function ConvertToGWYCategory(ByVal c As Category) As GWYCategory
        Select Case c
            Case Category.Cable
                Return GWYCategory.Cable
            Case Category.HSD
                Return GWYCategory.HSD
            Case Category.Telephoney
                Return GWYCategory.Telephoney
            Case Category.UnSpecified
                Return GWYCategory.UnSpecified
            Case Else
                Throw New ApplicationException("UnKnown Category")
        End Select
    End Function

    'Public Shared Function ConvertToUIItemType(ByVal type As BLItemType) As ItemType
    '  Select Case type
    '    Case BLItemType.Bundle
    '      Return ItemType.Bundle
    '    Case BLItemType.Feature
    '      Return ItemType.Feature
    '    Case BLItemType.Promotion
    '      Return ItemType.Promotion
    '    Case BLItemType.ServicePlan
    '      Return ItemType.ServicePlan
    '    Case Else
    '      Throw New ApplicationException("UnKnown Item Type")
    '  End Select
    'End Function

    'Public Shared Function ConvertToBLItemType(ByVal type As BLItemType) As ItemType
    '  Select Case type
    '    Case BLItemType.Bundle
    '      Return ItemType.Bundle
    '    Case BLItemType.Feature
    '      Return ItemType.Feature
    '    Case BLItemType.Promotion
    '      Return ItemType.Promotion
    '    Case BLItemType.ServicePlan
    '      Return ItemType.ServicePlan
    '    Case Else
    '      Throw New ApplicationException("UnKnown Item Type")
    '  End Select
    'End Function

    Public Shared Function ConvertTOUIFeatureType(ByVal fType As GWYFeatureType) As FeatureType
        Select Case fType
            Case GWYFeatureType.IsCustomization
                Return FeatureType.IsCustomization
            Case GWYFeatureType.IsIncluded
                Return FeatureType.IsIncluded
            Case GWYFeatureType.IsOptional
                Return FeatureType.IsOptional
            Case GWYFeatureType.IsPlaceholder
                Return FeatureType.IsPlaceholder
            Case GWYFeatureType.NotSpecified
                Return FeatureType.NotSpecified
            Case Else
                Throw New ApplicationException("UnKnown Feature Type")
        End Select
    End Function

    Public Shared Function ConvertTOGWYFeatureType(ByVal fType As FeatureType) As GWYFeatureType
        Select Case fType
            Case FeatureType.IsCustomization
                Return GWYFeatureType.IsCustomization
            Case FeatureType.IsIncluded
                Return GWYFeatureType.IsIncluded
            Case FeatureType.IsOptional
                Return GWYFeatureType.IsOptional
            Case FeatureType.IsPlaceholder
                Return GWYFeatureType.IsPlaceholder
            Case FeatureType.NotSpecified
                Return GWYFeatureType.NotSpecified
            Case Else
                Throw New ApplicationException("UnKnown Feature Type")
        End Select
    End Function

    Public Shared Function ConvertToUIOwnerType(ByVal type As GWYOwnerType) As OwnerType
        Select Case type
            Case GWYOwnerType.Bundle
                Return OwnerType.Bundle
            Case GWYOwnerType.Feature
                Return OwnerType.Feature
            Case GWYOwnerType.Other
                Return OwnerType.Other
            Case GWYOwnerType.ServicePlan
                Return OwnerType.ServicePlan
            Case Else
                Throw New ApplicationException("UnKnown Owner Type")
        End Select

    End Function

    Public Shared Function ConvertToGWYOwnerType(ByVal type As OwnerType) As GWYOwnerType
        Select Case type
            Case OwnerType.Bundle
                Return GWYOwnerType.Bundle
            Case OwnerType.Feature
                Return GWYOwnerType.Feature
            Case OwnerType.Other
                Return GWYOwnerType.Other
            Case OwnerType.ServicePlan
                Return GWYOwnerType.ServicePlan
            Case Else
                Throw New ApplicationException("UnKnown Owner Type")
        End Select

    End Function

    Public Shared Function ConvertToOwnerType(ByVal type As String) As OwnerType
        Select Case type
            Case OwnerType.Bundle.ToString
                Return OwnerType.Bundle
            Case OwnerType.Feature.ToString
                Return OwnerType.Feature
            Case OwnerType.Other.ToString
                Return OwnerType.Other
            Case OwnerType.ServicePlan.ToString
                Return OwnerType.ServicePlan
            Case OwnerType.ZipCode.ToString
                Return OwnerType.ZipCode
            Case Else
                Throw New ApplicationException("UnKnown Owner Type")
        End Select

    End Function

    Public Shared Function ConverToUIBillingVendorType(ByVal bv As GWYBillingVendorType) As BillingVendorType
        Select Case bv
            Case GWYBillingVendorType.CSG
                Return BillingVendorType.CSG
            Case GWYBillingVendorType.ICOM
                Return BillingVendorType.ICOM
            Case Else
                Throw New ApplicationException("Unknown Type")
        End Select
    End Function

    Public Shared Function ConverToGWYBillingVendorType(ByVal bv As BillingVendorType) As GWYBillingVendorType
        Select Case bv
            Case BillingVendorType.CSG
                Return GWYBillingVendorType.CSG
            Case BillingVendorType.ICOM
                Return GWYBillingVendorType.ICOM
            Case Else
                Throw New ApplicationException("Unknown Type")
        End Select
    End Function

    'Public Shared Function ConvertTOUIFeatureCategory(ByVal category As FeatureCategory) As FeatureCategory
    '  Select Case category
    '    Case GWYCategory.C
    '  End Select
    'End Function

    Public Shared Function ConvertToGwyCardType(ByVal type As String) As EntityG2BServices.CreditCardEnum
        Select Case type
            Case CreditCardType.Discover.ToString
                Return EntityG2BServices.CreditCardEnum.m_Discover
            Case CreditCardType.Master.ToString
                Return EntityG2BServices.CreditCardEnum.m_MC
            Case CreditCardType.Visa.ToString
                Return EntityG2BServices.CreditCardEnum.m_Visa
            Case Else
                Throw New ApplicationException("Unknown Type")
        End Select
    End Function

    Public Shared Sub ConvertGwyAddressToBLAddress(ByRef BLAddress As BLAddress, ByVal GwyAddress As Address)
        Try
            BLAddress.Street1 = GwyAddress.Street1
            BLAddress.Street2 = GwyAddress.Street2
            BLAddress.State = GwyAddress.State
            BLAddress.City = GwyAddress.City
            BLAddress.Zip = GwyAddress.Zip
            BLAddress.Zip4 = GwyAddress.Zip4
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Public Shared Function ConvertBLAddressToGwyAddress(ByVal address As BLAddress) As Address
        If Not address Is Nothing Then
            Dim zip4 As String
            If address.Zip4 Is String.Empty Then
                zip4 = Nothing
            Else
                zip4 = address.Zip4
            End If
            Dim gwyAddress As New Address(address.Street1, address.Street2, address.City, address.State, address.Zip, zip4)
            Return gwyAddress
        End If
        Return Nothing
    End Function

    Public Shared Function ConverToGWYLOB(ByVal blLOB As List(Of BLServiceType)) As List(Of ServiceType)
        Dim list As New List(Of ServiceType)
        For Each s As BLServiceType In blLOB
            list.Add(ConverToGWYServiceType(s))
        Next
        Return list
    End Function

    Public Shared Function ConverToGWYServiceType(ByVal service As BLServiceType) As ServiceType
        Select Case service
            Case BLServiceType.Basic
                Return ServiceType.Basic
            Case BLServiceType.Digital
                Return ServiceType.Digital
            Case BLServiceType.DVR
                Return ServiceType.DVR
            Case BLServiceType.HDTV
                Return ServiceType.HDTV
            Case BLServiceType.HSD
                Return ServiceType.HSD
            Case BLServiceType.Telephony
                Return ServiceType.Telephony
            Case BLServiceType.VOD
            Case Else
                Return ServiceType.NotSpecified
        End Select
    End Function

    Public Shared Function ConvertToGWYPriceFrequency(ByVal frequency As BLPriceFrequency) As PriceFrequency
        Select Case frequency
            Case BLPriceFrequency.Monthly
                Return PriceFrequency.Monthly
            Case BLPriceFrequency.OneTime
                Return PriceFrequency.OneTime
        End Select
    End Function

    Public Shared Function ConvertToUIPriceFrequency(ByVal frequency As PriceFrequency) As BLPriceFrequency
        Select Case frequency
            Case PriceFrequency.Monthly
                Return BLPriceFrequency.Monthly
            Case PriceFrequency.OneTime
                Return BLPriceFrequency.OneTime
        End Select
    End Function

    Public Shared Function ConvertToGWYInPutType(ByVal type As InputType) As GwyCustomizationInputType
        Select Case type
            Case InputType.Number
                Return GwyCustomizationInputType.Number
            Case InputType.Selection
                Return GwyCustomizationInputType.Selection
            Case InputType.Text
                Return GwyCustomizationInputType.Text
            Case Else
                Return GwyCustomizationInputType.Other
        End Select
    End Function

    Public Shared Function ConvertToUIInPutType(ByVal type As GwyCustomizationInputType) As InputType
        Select Case type
            Case GwyCustomizationInputType.Number
                Return InputType.Number
            Case GwyCustomizationInputType.Selection
                Return InputType.Selection
            Case GwyCustomizationInputType.Text
                Return InputType.Text
            Case Else
                Return InputType.Other
        End Select
    End Function

#End Region

End Class
