File tree Expand file tree Collapse file tree 5 files changed +44
-4
lines changed
LearningHub.Nhs.OpenApi.Services.Interface/Services
LearningHub.Nhs.OpenApi.Services/Services
WebAPI/LearningHub.Nhs.Database/Stored Procedures/Activity Expand file tree Collapse file tree 5 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,15 @@ public interface IMoodleApiService
3030 /// <param name="userId">Moodle user id.</param>
3131 /// <param name="months">pageNumber.</param>
3232 /// <returns> List of MoodleCourseResponseModel.</returns>
33- Task < List < MoodleEnrolledCourseResponseModel > > GetRecentEnrolledCoursesAsync ( int userId , int ? months = null ) ;
33+ Task < List < MoodleEnrolledCourseResponseModel > > GetRecentEnrolledCoursesAsync ( int userId , int ? months = null ) ;
34+
35+ /// <summary>
36+ /// GetEnrolledCoursesAsync.
37+ /// </summary>
38+ /// <param name="userId">Moodle user id.</param>
39+ /// <param name="months">pageNumber.</param>
40+ /// <returns> List of MoodleCourseResponseModel.</returns>
41+ Task < List < MoodleEnrolledCourseResponseModel > > GetEnrolledCoursesHistoryAsync ( int userId ) ;
3442
3543 /// <summary>
3644 /// GetEnrolledCoursesAsync.
Original file line number Diff line number Diff line change @@ -136,6 +136,38 @@ public async Task<List<MoodleEnrolledCourseResponseModel>> GetRecentEnrolledCour
136136 }
137137 }
138138
139+ /// <summary>
140+ /// GetEnrolledCoursesAsync.
141+ /// </summary>
142+ /// <param name="userId">Moodle user id.</param>
143+ /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
144+ public async Task < List < MoodleEnrolledCourseResponseModel > > GetEnrolledCoursesHistoryAsync ( int userId )
145+ {
146+ try
147+ {
148+ userId = 3 ;
149+ var parameters = new Dictionary < string , string >
150+ {
151+ { "userid" , userId . ToString ( ) }
152+ } ;
153+
154+ // Fetch enrolled courses
155+ var recentEnrolledCourses = await GetCallMoodleApiAsync < List < MoodleEnrolledCourseResponseModel > > (
156+ "mylearningservice_get_recent_courses" ,
157+ parameters
158+ ) ;
159+
160+ if ( recentEnrolledCourses == null || recentEnrolledCourses . Count == 0 )
161+ return new List < MoodleEnrolledCourseResponseModel > ( ) ;
162+
163+ return recentEnrolledCourses . ToList ( ) ;
164+ }
165+ catch ( Exception ex )
166+ {
167+ return null ;
168+ }
169+ }
170+
139171 /// <summary>
140172 /// GetUserLearningHistory.
141173 /// </summary>
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserLearningHistoryA
227227 {
228228 var result = await resourceActivityRepository . GetUserLearningHistory ( userId , requestModel ) ;
229229
230- var entrolledCourses = await this . moodleApiService . GetRecentEnrolledCoursesAsync ( userId ) ;
230+ var entrolledCourses = await this . moodleApiService . GetEnrolledCoursesHistoryAsync ( userId ) ;
231231
232232 List < MyLearningCombinedActivitiesViewModel > mappedMyLearningActivities = new ( ) ;
233233 List < MyLearningCombinedActivitiesViewModel > mappedEnrolledCourses = new ( ) ;
Original file line number Diff line number Diff line change 55--
66-- Modification History
77-- -----------------------------------------------------------------------------
8- ALTER PROCEDURE [activity].[GetUserRecentLearningActivities] (
8+ CREATE PROCEDURE [activity].[GetUserRecentLearningActivities] (
99 @userId INT
1010 )
1111AS
Original file line number Diff line number Diff line change 55--
66-- Modification History
77-- -----------------------------------------------------------------------------
8- ALTER PROCEDURE [activity].[GetUsersLearningHistory] (
8+ CREATE PROCEDURE [activity].[GetUsersLearningHistory] (
99 @userId INT
1010 )
1111AS
You can’t perform that action at this time.
0 commit comments