Imports DBUtilsDataTable
Imports log4net
Imports TelerikWinFormsApp2.Balances.Operator.BalanceActivityTypeCollection.Entities

Public Class BalanceActivityTypeColletionManager
    Private Shared ReadOnly log As ILog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)

#Region "constructor"

    Public Sub New()
        Try
            SetBalanceActivityTypeCollectionToList()
        Catch ex As Exception
            log.ErrorFormat(ex.StackTrace)
            Log.Error("BalanceActivityTypeColletionManager() - Load balance activity type collection Failed")
            MsgBox("Fel vid laddning av aktivitetstypsamling. Vid upprepning felanmäl felet till SPOC:en", MsgBoxStyle.OkOnly, "Felmeddelande")
            HasError = True
        End Try
    End Sub

#End Region

#Region "Properties"

    Public Property BalanceActivityTypeCollectionList As New List(Of BalanceActivityTypeCollectionItem)
    Public Property HasError() As Boolean = False

    Public ReadOnly Property BalanceActivityTypeCollectionListIndex(ByVal balanceActivityTypeCollectionID As Integer) As Integer
        Get
            Return GetBalanceActivityTypeCollectionListIndex(balanceActivityTypeCollectionID)
        End Get
    End Property

    Public ReadOnly Property BalanceActivityTypeCollection(ByVal balanceActivityID As Integer) As Object
        Get
            Return GetBalanceActivityTypeCollection(balanceActivityID)
        End Get
    End Property

#End Region

#Region "Methods"

    Private Sub SetBalanceActivityTypeCollectionToList()
        BalanceActivityTypeCollectionList.Clear()
        Try
            Dim item1 As New BalanceActivityTypeCollectionItem
            item1.BalanceActivityTypeCollectionID = 1
            item1.BalanceActivityID = 1
            item1.BalanceActivityTypeID = 1
            BalanceActivityTypeCollectionList.Add(item1)

            Dim item2 As New BalanceActivityTypeCollectionItem
            item2.BalanceActivityTypeCollectionID = 2
            item2.BalanceActivityID = 1
            item2.BalanceActivityTypeID = 1
            BalanceActivityTypeCollectionList.Add(item2)

            Dim item3 As New BalanceActivityTypeCollectionItem
            item3.BalanceActivityTypeCollectionID = 3
            item3.BalanceActivityID = 3
            item3.BalanceActivityTypeID = 1
            BalanceActivityTypeCollectionList.Add(item3)


        Catch ex As Exception
            Log.ErrorFormat(ex.StackTrace)
            Log.Error("BalanceActivityTypeColletionManager() - Failed when set balance activity type collection to list")
        End Try
    End Sub

#End Region

#Region "Functions"

    Private Function GetBalanceActivityTypeCollection(ByVal balanceActivityID As Integer) As Object
        Dim result As Object = Nothing
        Try
            result = BalanceActivityTypeCollectionList.FindAll(Function(item) item.BalanceActivityID = balanceActivityID)
        Catch ex As Exception

        End Try

        Return result
    End Function

    Private Function GetBalanceActivityTypeCollectionListIndex(ByVal balanceActivityTypeCollectionID As Integer) As Integer
        Dim result As Integer = -1I
        Try
            result = BalanceActivityTypeCollectionList.FindIndex(Function(item) item.BalanceActivityTypeCollectionID = balanceActivityTypeCollectionID)
        Catch ex As Exception
            Log.ErrorFormat(ex.StackTrace)
            Log.Error("BalanceActivityTypeColletionManager() - Failed when get balance activity type collection index")
        End Try

        Return result
    End Function

#End Region

End Class
