@@ -450,26 +450,29 @@ public async Task<DepartmentGroup> GetGroupForEventAsync(ProcessedNotification n
450450 //NotificationItem dynamicData = (NotificationItem)JsonConvert.DeserializeObject(data);
451451 NotificationItem dynamicData = ObjectSerialization . Deserialize < NotificationItem > ( notification . Data ) ;
452452
453- if ( notification . Type == EventTypes . UnitStatusChanged )
453+ if ( dynamicData != null )
454454 {
455- var unitEvent = await _unitsService . GetUnitStateByIdAsync ( dynamicData . StateId ) ;
456- return await _departmentGroupsService . GetGroupByIdAsync ( unitEvent . Unit . StationGroupId . GetValueOrDefault ( ) ) ;
457- }
458- else if ( notification . Type == EventTypes . PersonnelStatusChanged )
459- {
460- var userStaffing = await _userStateService . GetUserStateByIdAsync ( dynamicData . StateId ) ;
461- var group = await _departmentGroupsService . GetGroupForUserAsync ( userStaffing . UserId , notification . DepartmentId ) ;
462- return group ;
463- }
464- else if ( notification . Type == EventTypes . PersonnelStatusChanged )
465- {
466- var actionLog = await _actionLogsService . GetActionLogByIdAsync ( dynamicData . StateId ) ;
467- var group = await _departmentGroupsService . GetGroupForUserAsync ( actionLog . UserId , notification . DepartmentId ) ;
468- return group ;
469- }
470- else if ( notification . Type == EventTypes . UserAssignedToGroup )
471- {
472- return await _departmentGroupsService . GetGroupByIdAsync ( dynamicData . GroupId ) ;
455+ if ( notification . Type == EventTypes . UnitStatusChanged )
456+ {
457+ var unitEvent = await _unitsService . GetUnitStateByIdAsync ( dynamicData . StateId ) ;
458+ return await _departmentGroupsService . GetGroupByIdAsync ( unitEvent . Unit . StationGroupId . GetValueOrDefault ( ) ) ;
459+ }
460+ else if ( notification . Type == EventTypes . PersonnelStatusChanged )
461+ {
462+ var userStaffing = await _userStateService . GetUserStateByIdAsync ( dynamicData . StateId ) ;
463+ var group = await _departmentGroupsService . GetGroupForUserAsync ( userStaffing . UserId , notification . DepartmentId ) ;
464+ return group ;
465+ }
466+ else if ( notification . Type == EventTypes . PersonnelStatusChanged )
467+ {
468+ var actionLog = await _actionLogsService . GetActionLogByIdAsync ( dynamicData . StateId ) ;
469+ var group = await _departmentGroupsService . GetGroupForUserAsync ( actionLog . UserId , notification . DepartmentId ) ;
470+ return group ;
471+ }
472+ else if ( notification . Type == EventTypes . UserAssignedToGroup )
473+ {
474+ return await _departmentGroupsService . GetGroupByIdAsync ( dynamicData . GroupId ) ;
475+ }
473476 }
474477
475478 return null ;
@@ -953,7 +956,7 @@ public async Task<string> GetMessageForTypeAsync(ProcessedNotification notificat
953956
954957 public async Task < bool > DeleteDepartmentNotificationByIdAsync ( int notificationId , CancellationToken cancellationToken = default ( CancellationToken ) )
955958 {
956- var notification = await
959+ var notification = await
957960 _departmentNotificationRepository . GetByIdAsync ( notificationId ) ;
958961
959962 if ( notification != null )
0 commit comments