@@ -131,12 +131,7 @@ public IActionResult Index(
131131
132132            var  centreId  =  User . GetCentreIdKnownNotNull ( ) ; 
133133            var  adminCategoryId  =  User . GetAdminCategoryId ( ) ; 
134-             var  selfAssessmentCategoryId  =  selfAssessmentService . GetSelfAssessmentCategoryId ( ( int ) selfAssessmentId ) ; 
135134
136-             if  ( adminCategoryId  >  0  &&  adminCategoryId  !=  selfAssessmentCategoryId ) 
137-             { 
138-                 return  RedirectToAction ( "StatusCode" ,  "LearningSolutions" ,  new  {  code  =  403  } ) ; 
139-             } 
140135
141136            bool ?  isDelegateActive ,  isProgressLocked ,  removed ,  hasCompleted ,  submitted ,  signedOff ; 
142137            isDelegateActive  =  isProgressLocked  =  removed  =  hasCompleted  =  submitted  =  signedOff  =  null ; 
@@ -216,7 +211,7 @@ public IActionResult Index(
216211            { 
217212                var  courseDelegatesData  =  new  CourseDelegatesData ( ) ; 
218213                var  selfAssessmentDelegatesData  =  new  SelfAssessmentDelegatesData ( ) ; 
219-                 var  resultCount   =   0 ; 
214+                 int ?  resultCount ; 
220215                if  ( isCourseDelegate ) 
221216                { 
222217                    ( courseDelegatesData ,  resultCount )  =  courseDelegatesService . GetCoursesAndCourseDelegatesPerPageForCentre ( searchString  ??  string . Empty ,  offSet ,  itemsPerPage  ??  0 ,  sortBy ,  sortDirection , 
@@ -238,14 +233,20 @@ public IActionResult Index(
238233                else 
239234                { 
240235                    ( selfAssessmentDelegatesData ,  resultCount )  =  selfAssessmentService . GetSelfAssessmentDelegatesPerPage ( searchString  ??  string . Empty ,  offSet ,  itemsPerPage  ??  0 ,  sortBy ,  sortDirection , 
241-                     selfAssessmentId ,  centreId ,  isDelegateActive ,  removed ,  submitted ,  signedOff ) ; 
236+                     selfAssessmentId ,  centreId ,  isDelegateActive ,  removed ,  submitted ,  signedOff ,  adminCategoryId ) ; 
237+ 
238+                     if  ( selfAssessmentDelegatesData ? . Delegates  ==  null  &&  resultCount  ==  null ) 
239+                     { 
240+                         //redirect as unauthorized through null comparisions when category Id is a mismatch. 
241+                         return  RedirectToAction ( "StatusCode" ,  "LearningSolutions" ,  new  {  code  =  403  } ) ; 
242+                     } 
242243
243244                    if  ( selfAssessmentDelegatesData ? . Delegates ? . Count ( )  ==  0  &&  resultCount  >  0 ) 
244245                    { 
245246                        page  =  1 ;  offSet  =  0 ; 
246247                        ( selfAssessmentDelegatesData ,  resultCount )  =  selfAssessmentService . GetSelfAssessmentDelegatesPerPage ( searchString  ??  string . Empty ,  offSet ,  itemsPerPage  ??  0 ,  sortBy ,  sortDirection , 
247-                             selfAssessmentId ,  centreId ,  isDelegateActive ,  removed ,  submitted ,  signedOff ) ; 
248-                     } 
248+                             selfAssessmentId ,  centreId ,  isDelegateActive ,  removed ,  submitted ,  signedOff ,   adminCategoryId ) ; 
249+                     }                      
249250
250251                    var  adminId  =  User . GetCustomClaimAsRequiredInt ( CustomClaimTypes . UserAdminId ) ; 
251252
@@ -280,7 +281,7 @@ public IActionResult Index(
280281                { 
281282                    var  result  =  paginateService . Paginate ( 
282283                    courseDelegatesData . Delegates , 
283-                     resultCount , 
284+                     ( int ) resultCount , 
284285                    new  PaginationOptions ( page ,  itemsPerPage ) , 
285286                    new  FilterOptions ( existingFilterString ,  availableFilters ,  CourseDelegateAccountStatusFilterOptions . Active . FilterValue ) , 
286287                    searchString , 
@@ -298,7 +299,7 @@ public IActionResult Index(
298299                { 
299300                    var  result  =  paginateService . Paginate ( 
300301                    selfAssessmentDelegatesData . Delegates , 
301-                     resultCount , 
302+                     ( int ) resultCount , 
302303                    new  PaginationOptions ( page ,  itemsPerPage ) , 
303304                    new  FilterOptions ( existingFilterString ,  availableFilters ,  CourseDelegateAccountStatusFilterOptions . Active . FilterValue ) , 
304305                    searchString , 
0 commit comments