@@ -40,6 +40,7 @@ public class HomeController : BaseController
4040 private readonly IDashboardService dashboardService ;
4141 private readonly IContentService contentService ;
4242 private readonly IFeatureManager featureManager ;
43+ private readonly IUserGroupService userGroupService ;
4344 private readonly Microsoft . Extensions . Configuration . IConfiguration configuration ;
4445
4546 /// <summary>
@@ -55,6 +56,7 @@ public class HomeController : BaseController
5556 /// <param name="dashboardService">Dashboard service.</param>
5657 /// <param name="contentService">Content service.</param>
5758 /// <param name="featureManager"> featureManager.</param>
59+ /// <param name="userGroupService"> userGroupService.</param>
5860 /// <param name="configuration"> config.</param>
5961 public HomeController (
6062 IHttpClientFactory httpClientFactory ,
@@ -67,6 +69,7 @@ public HomeController(
6769 IDashboardService dashboardService ,
6870 IContentService contentService ,
6971 IFeatureManager featureManager ,
72+ IUserGroupService userGroupService ,
7073 Microsoft . Extensions . Configuration . IConfiguration configuration )
7174 : base ( hostingEnvironment , httpClientFactory , logger , settings . Value )
7275 {
@@ -76,6 +79,7 @@ public HomeController(
7679 this . dashboardService = dashboardService ;
7780 this . contentService = contentService ;
7881 this . featureManager = featureManager ;
82+ this . userGroupService = userGroupService ;
7983 this . configuration = configuration ;
8084 }
8185
@@ -212,6 +216,7 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
212216 var learningTask = this . dashboardService . GetMyAccessLearningsAsync ( myLearningDashboard , 1 ) ;
213217 var resourcesTask = this . dashboardService . GetResourcesAsync ( resourceDashboard , 1 ) ;
214218 var cataloguesTask = this . dashboardService . GetCataloguesAsync ( catalogueDashboard , 1 ) ;
219+ var userGroupsTask = this . userGroupService . UserHasCatalogueContributionPermission ( ) ;
215220
216221 var enrolledCoursesTask = Task . FromResult ( new List < MoodleCourseResponseViewModel > ( ) ) ;
217222 var enableMoodle = Task . Run ( ( ) => this . featureManager . IsEnabledAsync ( FeatureFlags . EnableMoodle ) ) . Result ;
@@ -222,7 +227,7 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
222227 enrolledCoursesTask = this . dashboardService . GetEnrolledCoursesFromMoodleAsync ( this . CurrentMoodleUserId , 1 ) ;
223228 }
224229
225- await Task . WhenAll ( learningTask , resourcesTask , cataloguesTask ) ;
230+ await Task . WhenAll ( learningTask , resourcesTask , cataloguesTask , userGroupsTask ) ;
226231
227232 var model = new DashboardViewModel ( )
228233 {
@@ -231,7 +236,8 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
231236 Catalogues = await cataloguesTask ,
232237 EnrolledCourses = await enrolledCoursesTask ,
233238 } ;
234-
239+ var userHasContributePermission = await userGroupsTask ;
240+ this . ViewBag . userHasContributePermission = userHasContributePermission ;
235241 if ( ! string . IsNullOrEmpty ( this . Request . Query [ "preview" ] ) && Convert . ToBoolean ( this . Request . Query [ "preview" ] ) )
236242 {
237243 return this . View ( "LandingPage" , await this . GetLandingPageContent ( Convert . ToBoolean ( this . Request . Query [ "preview" ] ) ) ) ;
0 commit comments