Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IworkItemManager.vb =================================================================== diff -u -r1681 -r1712 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IworkItemManager.vb (.../IworkItemManager.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IworkItemManager.vb (.../IworkItemManager.vb) (revision 1712) @@ -4,5 +4,5 @@ ''' ''' The index of the work post, 0 based ''' Collection of the work items - Function GiveWorkItems(workPostIndex As Integer) As List(Of IWorkItem) + Function GiveWorkItems(workPostIndex As Integer) As ICollection(Of IWorkItem) End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/DomainController.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/DomainController.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/DomainController.vb (revision 1712) @@ -0,0 +1,53 @@ +Public Class DomainController + Implements IDomainController + + Private ReadOnly _employeeManager As IEmployeeManager + Private ReadOnly _workItemManager As IWorkItemManager + +#Region "Singleton pattern" + + Private Shared _instance As DomainController + + Private Sub New() + 'Initialise managers. + _employeeManager = New EmployeeManager + _workItemManager = New WorkItemManager + End Sub + + ''' + ''' Gets an instance of the domain controller. Only one instance exists. + ''' + ''' The instance of the domain controller + Public Shared Function GetInstance() As IDomainController + 'If no instance is present, initialise. + If _instance Is Nothing Then + _instance = New DomainController() + End If + 'Return instance. + Return _instance + End Function +#End Region + +#Region "Employees" + + ''' + Public Function GetEmployees() As ICollection(Of IEmployee) Implements IDomainController.GetEmployees + Return _employeeManager.Employees + End Function + + ''' + Public Sub SelectEmployee(employee As IEmployee) Implements IDomainController.SelectEmployee + _employeeManager.SelectEmployee(employee) + End Sub + +#End Region + +#Region "Work items" + + ''' + Function GiveWorkItems(workPostIndex As Integer) As ICollection(Of IWorkItem) Implements IDomainController.GiveWorkItems + Return _workItemManager.GiveWorkItems(workPostIndex) + End Function +#End Region + +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IEmployeeManager.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IEmployeeManager.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/IEmployeeManager.vb (revision 1712) @@ -0,0 +1,9 @@ +Public Interface IEmployeeManager + ReadOnly Property Employees As ICollection(Of IEmployee) + + ''' + ''' Select and store the chosen employee. + ''' + ''' + Sub SelectEmployee(employee As IEmployee) +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/WorkItemManager.vb =================================================================== diff -u -r1681 -r1712 --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/WorkItemManager.vb (.../WorkItemManager.vb) (revision 1681) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/WorkItemManager.vb (.../WorkItemManager.vb) (revision 1712) @@ -2,7 +2,7 @@ Implements IWorkItemManager ''' - Public Function GiveWorkItems(workPostIndex As Integer) As List(Of IWorkItem) Implements IWorkItemManager.GiveWorkItems + Public Function GiveWorkItems(workPostIndex As Integer) As ICollection(Of IWorkItem) Implements IWorkItemManager.GiveWorkItems Return CacheMapper.GetData(workPostIndex) End Function End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/IDomainController.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/IDomainController.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/controllers/IDomainController.vb (revision 1712) @@ -0,0 +1,25 @@ +Public Interface IDomainController +#Region "Employees" + + ''' + ''' Gets a collection of all the employees. + ''' + ''' + Function GetEmployees() As ICollection(Of IEmployee) + + ''' + ''' Select an employee as one of the usable employees. + ''' + ''' + sub SelectEmployee(employee As IEmployee) +#End Region + +#Region "Work items" + ''' + ''' Fetches the work items for a certain work post. + ''' + ''' The index of the work post, 0 based + ''' Collection of the work items + Function GiveWorkItems(workPostIndex As Integer) As ICollection(Of IWorkItem) +#End Region +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/domain/managers/implementations/EmployeeManager.vb (revision 1712) @@ -0,0 +1,21 @@ +Public Class EmployeeManager + Implements IEmployeeManager + + Private ReadOnly _employees As ICollection(Of IEmployee) + Public ReadOnly Property Employees As ICollection(Of IEmployee) Implements IEmployeeManager.Employees + Get + Return New HashSet(Of IEmployee)(_employees) + End Get + End Property + + Sub New() + 'Initial fetching of employees, then stored. + _employees = EmployeesDatabaseMapper.FetchEmployees() + End Sub + + ''' + Public Sub SelectEmployee(employee As IEmployee) Implements IEmployeeManager.SelectEmployee + + End Sub + +End Class Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings =================================================================== diff -u -r1682 -r1712 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1682) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj.DotSettings (.../ActiviteitenOpvolging.vbproj.DotSettings) (revision 1712) @@ -3,6 +3,7 @@ True True True + True True True True Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb =================================================================== diff -u -r1711 -r1712 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1711) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1712) @@ -24,8 +24,6 @@ 'Load the user controls with the data grids. LoadDataGridUserControls() - - FetchEmployees() Catch ex As Exception MessageBox.Show(ex.Message, "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error) Application.Exit()