1717 /// </summary>
1818 public class DashboardService : BaseService < DashboardService > , IDashboardService
1919 {
20+ private readonly IMoodleApiService moodleApiService ;
21+
2022 /// <summary>
2123 /// Initializes a new instance of the <see cref="DashboardService"/> class.
2224 /// </summary>
2325 /// <param name="learningHubHttpClient">learningHubHttpClient.</param>
2426 /// <param name="openApiHttpClient">The Open Api Http Client.</param>
2527 /// <param name="logger">logger.</param>
26- public DashboardService ( ILearningHubHttpClient learningHubHttpClient , IOpenApiHttpClient openApiHttpClient , ILogger < DashboardService > logger )
28+ /// <param name="moodleApiService">MoodleApiService.</param>
29+ public DashboardService ( ILearningHubHttpClient learningHubHttpClient , IOpenApiHttpClient openApiHttpClient , ILogger < DashboardService > logger , IMoodleApiService moodleApiService )
2730 : base ( learningHubHttpClient , openApiHttpClient , logger )
2831 {
32+ this . moodleApiService = moodleApiService ;
2933 }
3034
3135 /// <summary>
@@ -124,8 +128,7 @@ public async Task<DashboardResourceResponseViewModel> GetResourcesAsync(string d
124128 public async Task < List < MoodleCourseResponseModel > > GetEnrolledCoursesFromMoodleAsync ( int currentUserId , int pageNumber )
125129 {
126130 List < MoodleCourseResponseModel > viewmodel = new List < MoodleCourseResponseModel > { } ;
127- MoodleApiService moodleApiService = new MoodleApiService ( this . OpenApiHttpClient ) ;
128- viewmodel = await moodleApiService . GetEnrolledCoursesAsync ( currentUserId , pageNumber ) ;
131+ viewmodel = await this . moodleApiService . GetEnrolledCoursesAsync ( currentUserId , pageNumber ) ;
129132 return viewmodel ;
130133 }
131134
@@ -136,8 +139,7 @@ public async Task<List<MoodleCourseResponseModel>> GetEnrolledCoursesFromMoodleA
136139 /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
137140 public async Task < int > GetMoodleUserIdAsync ( int currentUserId )
138141 {
139- MoodleApiService moodleApiService = new MoodleApiService ( this . OpenApiHttpClient ) ;
140- var moodleUserId = await moodleApiService . GetMoodleUserIdByUsernameAsync ( currentUserId ) ;
142+ var moodleUserId = await this . moodleApiService . GetMoodleUserIdByUsernameAsync ( currentUserId ) ;
141143 return moodleUserId ;
142144 }
143145
0 commit comments