Imports System.Collections.Generic
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports System.Text


<Serializable()> _
Public Class BLBundle
    Implements ICartItem

    Public m_gwyBundle As Bundle
    Private m_serviceType As ServiceType
    Private m_selected As Boolean = False
    Private m_available As Boolean = True
    Private m_removable As Boolean = True
    Private m_visible As Boolean = True
    ' Private _installPrice As Decimal
    'Private _installDescription As String
    Private m_children As Dictionary(Of String, ISubCartItem)
    Private m_requirements As String

    Public Sub New(ByVal b As Bundle, ByVal servicePlans As Dictionary(Of String, ISubCartItem))
        m_gwyBundle = b
        m_children = servicePlans
        If b IsNot Nothing Then
            If b.VideoExtension IsNot Nothing Then
                If b.VideoExtension.Requirements IsNot Nothing Then
                    Me.Requirements = b.VideoExtension.Requirements
                End If
            End If
            If b.DataExtension IsNot Nothing Then
                If b.DataExtension.Requirements IsNot Nothing Then
                    If Me.Requirements IsNot Nothing AndAlso Me.Requirements <> String.Empty Then
                        Me.Requirements += "<BR><BR>"
                    End If
                    Me.Requirements += b.DataExtension.Requirements
                End If
            End If
            If b.VoiceExtension IsNot Nothing Then
                If b.VoiceExtension.Requirements IsNot Nothing Then
                    If Me.Requirements IsNot Nothing AndAlso Me.Requirements <> String.Empty Then
                        Me.Requirements += "<BR><BR>"
                    End If
                    Me.Requirements += b.VoiceExtension.Requirements
                End If
            End If
        End If
    End Sub

    Public ReadOnly Property ID() As String Implements ICartItem.ID
        Get
            Return ItemType.Bundle & m_gwyBundle.ID
        End Get
    End Property

    Public ReadOnly Property Name() As String Implements ICartItem.Name
        Get
            Return m_gwyBundle.Name
        End Get
    End Property

    Public ReadOnly Property Description() As String Implements ICartItem.Description
        Get
            Return m_gwyBundle.Description
        End Get
    End Property

    Public ReadOnly Property InstallPrice() As Decimal Implements ICartItem.InstallPrice
        Get
            Return m_gwyBundle.InstallPrice
        End Get
    End Property

    Public ReadOnly Property InstallDescription() As String Implements ICartItem.InstallDescription
        Get
            Return m_gwyBundle.InstallDescription
        End Get
    End Property

    Public ReadOnly Property ContractDescription() As String Implements ICartItem.ContractDescription
        Get
            Return m_gwyBundle.Contract.Description
        End Get
    End Property

    Public ReadOnly Property ContractTermsAndConditions() As String Implements ICartItem.ContractTermsAndConditions
        Get
            Return m_gwyBundle.Contract.TermsAndConditions
        End Get
    End Property

    Public Property Requirements() As String Implements ICartItem.Requirements
        Get

            '

            '            ' loop thru the service plans for this bundle to get the bundle's requirements. 
            '            ' since the bundle itself has no definition of a requirements property
            '            Dim sb As New StringBuilder(1000)
            '            Dim iItem As Integer = 0
            '            If (Me.m_children IsNot Nothing) Then
            '                For Each kvp As KeyValuePair(Of String, ISubCartItem) In Me.m_children
            '                    sb.Append(CType(kvp.Value, BLServicePlan).Requirements & "-")
            '#If DEBUG Then
            '                    sb.Append(iItem & " ")
            '                    iItem += 1
            '#End If
            '                Next
            '            End If

            '            Return sb.ToString()
            Return m_requirements
        End Get
        Set(ByVal value As String)
            m_requirements = value
        End Set
    End Property

    Public Property ListPrice() As Decimal Implements ICartItem.ListPrice
        Get
            Return m_gwyBundle.ListPrice
        End Get
        Set(ByVal value As Decimal)
            m_gwyBundle.ListPrice = value
        End Set
    End Property

    Private Property BPrice() As Decimal Implements ICartItem.Price
        Get
            Return m_gwyBundle.Price
        End Get
        Set(ByVal value As Decimal)
            m_gwyBundle.Price = value
        End Set
    End Property

    Public Property Price() As Decimal
        Get
            Return m_gwyBundle.Price
        End Get
        Set(ByVal value As Decimal)
            m_gwyBundle.Price = value
        End Set
    End Property

    Public ReadOnly Property Category() As Category Implements ICartItem.Category
        Get
            Return Common.ConvertToUICategory(m_gwyBundle.Category)
        End Get
    End Property

    Public ReadOnly Property ServiceType() As ServiceType
        Get
            Return m_serviceType
        End Get
    End Property


    Public ReadOnly Property Type() As ItemType Implements ICartItem.Type
        Get
            Return ItemType.Bundle
        End Get
    End Property

    Public Property Selected() As Boolean Implements ICartItem.IsSelected
        Get
            Return m_selected
        End Get
        Set(ByVal value As Boolean)
            m_selected = value
        End Set
    End Property

    Public Property IsSelected() As Boolean
        Get
            Return m_selected
        End Get
        Set(ByVal value As Boolean)
            m_selected = value
        End Set
    End Property

    Public ReadOnly Property Available() As Boolean Implements ICartItem.IsAvailable
        Get
            Return m_available
        End Get
    End Property

    Public Property IsAvailable() As Boolean
        Get
            Return m_available
        End Get
        Set(ByVal value As Boolean)
            m_available = value
        End Set
    End Property

    Public ReadOnly Property Removable() As Boolean Implements ICartItem.IsRemovable
        Get
            Return Removable
        End Get
    End Property

    Public Property ISRemovable() As Boolean
        Get
            Return m_removable
        End Get
        Set(ByVal value As Boolean)
            m_removable = value
        End Set
    End Property

    Public ReadOnly Property IsVisible() As Boolean Implements ICartItem.IsVisisble
        Get
            Return m_visible
        End Get
    End Property

    Public WriteOnly Property Visible() As Boolean
        Set(ByVal value As Boolean)
            m_visible = value
        End Set
    End Property

    Public ReadOnly Property ServicePlans() As Dictionary(Of String, ISubCartItem) Implements ICartItem.Children
        Get
            Return m_children
        End Get
    End Property

    Public ReadOnly Property PromotionName() As String Implements ICartItem.PromotionName
        Get
            Return m_gwyBundle.PromoName
        End Get
    End Property

    Public ReadOnly Property PromoDisclaimer() As String Implements ICartItem.PromotionDisclaimer
        Get
            Return m_gwyBundle.PromoDisclaimer
        End Get
    End Property

    Public ReadOnly Property MarketingInfo() As String Implements ICartItem.MarketingInfo
        Get
            Return m_gwyBundle.MarketingInfo
        End Get
    End Property

    Public ReadOnly Property MarketingDetail() As String Implements ICartItem.MarketingDetail
        Get
            Return m_gwyBundle.MarketingDetail
        End Get
    End Property
End Class
