@@ -641,10 +641,10 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
641641 call . IndoorMapFloorId = null ;
642642 }
643643
644- List < CallDispatch > existingDispatches = new List < CallDispatch > ( call . Dispatches ) ;
645- List < CallDispatchGroup > existingGroupDispatches = new List < CallDispatchGroup > ( call . GroupDispatches ) ;
646- List < CallDispatchUnit > existingUnitDispatches = new List < CallDispatchUnit > ( call . UnitDispatches ) ;
647- List < CallDispatchRole > existingRoleDispatches = new List < CallDispatchRole > ( call . RoleDispatches ) ;
644+ List < CallDispatch > existingDispatches = new List < CallDispatch > ( call . Dispatches ?? Enumerable . Empty < CallDispatch > ( ) ) ;
645+ List < CallDispatchGroup > existingGroupDispatches = new List < CallDispatchGroup > ( call . GroupDispatches ?? Enumerable . Empty < CallDispatchGroup > ( ) ) ;
646+ List < CallDispatchUnit > existingUnitDispatches = new List < CallDispatchUnit > ( call . UnitDispatches ?? Enumerable . Empty < CallDispatchUnit > ( ) ) ;
647+ List < CallDispatchRole > existingRoleDispatches = new List < CallDispatchRole > ( call . RoleDispatches ?? Enumerable . Empty < CallDispatchRole > ( ) ) ;
648648
649649 List < string > dispatchingUserIds = new List < string > ( ) ;
650650 List < int > dispatchingGroupIds = new List < int > ( ) ;
@@ -893,10 +893,10 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
893893 // Send cancel notifications to removed entities
894894 if ( model . NotifyCancelledEntities )
895895 {
896- var savedUserIds = new HashSet < string > ( call . Dispatches . Select ( x => x . UserId ) ) ;
897- var savedGroupIds = new HashSet < int > ( call . GroupDispatches . Select ( x => x . DepartmentGroupId ) ) ;
898- var savedUnitIds = new HashSet < int > ( call . UnitDispatches . Select ( x => x . UnitId ) ) ;
899- var savedRoleIds = new HashSet < int > ( call . RoleDispatches . Select ( x => x . RoleId ) ) ;
896+ var savedUserIds = new HashSet < string > ( ( call . Dispatches ?? Enumerable . Empty < CallDispatch > ( ) ) . Select ( x => x . UserId ) ) ;
897+ var savedGroupIds = new HashSet < int > ( ( call . GroupDispatches ?? Enumerable . Empty < CallDispatchGroup > ( ) ) . Select ( x => x . DepartmentGroupId ) ) ;
898+ var savedUnitIds = new HashSet < int > ( ( call . UnitDispatches ?? Enumerable . Empty < CallDispatchUnit > ( ) ) . Select ( x => x . UnitId ) ) ;
899+ var savedRoleIds = new HashSet < int > ( ( call . RoleDispatches ?? Enumerable . Empty < CallDispatchRole > ( ) ) . Select ( x => x . RoleId ) ) ;
900900
901901 var cancelledUserIds = existingDispatches . Select ( x => x . UserId )
902902 . Where ( y => ! savedUserIds . Contains ( y ) ) . ToList ( ) ;
@@ -912,13 +912,13 @@ public async Task<IActionResult> UpdateCall(UpdateCallView model, IFormCollectio
912912 var departmentNumber = await _departmentSettingsService . GetTextToCallNumberForDepartmentAsync ( DepartmentId ) ;
913913
914914 // Build set of still-dispatched user IDs for dedup
915- var stillDispatchedUserIds = new HashSet < string > ( call . Dispatches . Select ( x => x . UserId ) ) ;
916- foreach ( var gd in call . GroupDispatches )
915+ var stillDispatchedUserIds = new HashSet < string > ( ( call . Dispatches ?? Enumerable . Empty < CallDispatch > ( ) ) . Select ( x => x . UserId ) ) ;
916+ foreach ( var gd in call . GroupDispatches ?? Enumerable . Empty < CallDispatchGroup > ( ) )
917917 {
918918 var members = await _departmentGroupsService . GetAllMembersForGroupAsync ( gd . DepartmentGroupId ) ;
919919 foreach ( var m in members ) stillDispatchedUserIds . Add ( m . UserId ) ;
920920 }
921- foreach ( var rd in call . RoleDispatches )
921+ foreach ( var rd in call . RoleDispatches ?? Enumerable . Empty < CallDispatchRole > ( ) )
922922 {
923923 var members = await _personnelRolesService . GetAllMembersOfRoleAsync ( rd . RoleId ) ;
924924 foreach ( var m in members ) stillDispatchedUserIds . Add ( m . UserId ) ;
0 commit comments