1616 using Microsoft . FeatureManagement ;
1717 using Microsoft . FeatureManagement . Mvc ;
1818 using System ;
19+ using System . Linq ;
1920 using System . Threading . Tasks ;
20-
2121 [ FeatureGate ( FeatureFlags . RefactoredTrackingSystem ) ]
2222 [ Authorize ( Policy = CustomPolicies . UserCentreAdmin ) ]
2323 [ SetDlsSubApplication ( nameof ( DlsSubApplication . TrackingSystem ) ) ]
@@ -33,13 +33,15 @@ public class SelfAssessmentReportsController : Controller
3333 private readonly string workbookName ;
3434 private readonly string viewName ;
3535 private readonly ISelfAssessmentService selfAssessmentService ;
36+ private readonly ICentreSelfAssessmentsService centreSelfAssessmentsService ;
3637 private readonly IFeatureManager featureManager ;
3738 public SelfAssessmentReportsController (
3839 ISelfAssessmentReportService selfAssessmentReportService ,
3940 ITableauConnectionHelperService tableauConnectionHelper ,
4041 IClockUtility clockUtility ,
4142 IConfiguration config ,
4243 ISelfAssessmentService selfAssessmentService ,
44+ ICentreSelfAssessmentsService centreSelfAssessmentsService ,
4345 IFeatureManager featureManager
4446 )
4547 {
@@ -51,6 +53,7 @@ IFeatureManager featureManager
5153 workbookName = config . GetTableauWorkbookName ( ) ;
5254 viewName = config . GetTableauViewName ( ) ;
5355 this . selfAssessmentService = selfAssessmentService ;
56+ this . centreSelfAssessmentsService = centreSelfAssessmentsService ;
5457 this . featureManager = featureManager ;
5558 }
5659 [ Route ( "/TrackingSystem/Centre/Reports/SelfAssessments" ) ]
@@ -59,10 +62,12 @@ public async Task<IActionResult> IndexAsync()
5962 var centreId = User . GetCentreId ( ) ;
6063 var adminCategoryId = User . GetAdminCategoryId ( ) ;
6164 var categoryId = this . selfAssessmentService . GetSelfAssessmentCategoryId ( 1 ) ;
65+ var selfAssessments = centreSelfAssessmentsService . GetCentreSelfAssessments ( centreId . Value ) ;
66+ var dSATreportIsPublish = selfAssessments . Any ( x => x . SelfAssessmentId == 1 ) ;
6267 var tableauFlag = await featureManager . IsEnabledAsync ( FeatureFlags . TableauSelfAssessmentDashboards ) ;
6368 var tableauQueryOverride = string . Equals ( Request . Query [ "tableaulink" ] , "true" , StringComparison . OrdinalIgnoreCase ) ;
6469 var showTableauLink = tableauFlag || tableauQueryOverride ;
65- var model = new SelfAssessmentReportsViewModel ( selfAssessmentReportService . GetSelfAssessmentsForReportList ( ( int ) centreId , adminCategoryId ) , adminCategoryId , categoryId , showTableauLink ) ;
70+ var model = new SelfAssessmentReportsViewModel ( selfAssessmentReportService . GetSelfAssessmentsForReportList ( ( int ) centreId , adminCategoryId ) , adminCategoryId , categoryId , dSATreportIsPublish , showTableauLink ) ;
6671 return View ( model ) ;
6772 }
6873 [ HttpGet ]
0 commit comments