Index: ActiviteitenOpvolging/ProductiePitching/mappers/CacheMapper.vb =================================================================== diff -u -r1764 -r1790 --- ActiviteitenOpvolging/ProductiePitching/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1764) +++ ActiviteitenOpvolging/ProductiePitching/mappers/CacheMapper.vb (.../CacheMapper.vb) (revision 1790) @@ -166,7 +166,14 @@ Dim employeeInitials = ExtractItemFromDataReader(dr, $"Gebruiker_{i}", String.Empty) Dim employee As IEmployee = If(employeeInitials.Equals(String.Empty), Nothing, employees.FirstOrDefault(Function(employeeToCheck) employeeToCheck.Initials.Equals(employeeInitials))) 'Set the current state based on the enum value. If the quantity is 0, the status is automatically zero. - .State = ConvertEnumValueToActivityState(If(.QuantityToProduce = 0, ActivityStateEnum.Zero, ActivityStateEnumMapper.GetActivityStateFromLetter(ExtractItemFromDataReader(Of Char)(dr, $"Status_{i}"))), activity, employee) + Dim stateValue = ActivityStateEnum.Zero + If (.QuantityToProduce > 0) Then + stateValue = ActivityStateEnumMapper.GetActivityStateFromLetter(ExtractItemFromDataReader(Of Char)(dr, $"Status_{i}")) + If (employee Is Nothing) Then + employee = DummyEmployee() + End If + End If + .State = ConvertEnumValueToActivityState(stateValue, activity, employee) End With 'Add to collection of activities. activities.Add(activity) @@ -176,6 +183,18 @@ Return activities End Function + Private Function DummyEmployee() As Employee + Dim dummy As Employee = New Employee() + With dummy + .FirstName = "VH" + .LastName = "Automation" + .PersonelNumber = 0 + .Number = 0 + .Initials = "" + End With + Return dummy + End Function + ''' ''' Get the correct amount of activities. '''