Пример #1
0
        public List <JoinedCourseDTO> ListJoinedCourses(Guid userId)
        {
            List <JoinedCourseDTO> response = courseRepository.ListJoinedCourses(userId).Select(x => new JoinedCourseDTO
            {
                Id           = x.Id,
                Name         = x.Name,
                ImageIndex   = x.ImageIndex,
                Description  = x.Description,
                CurrentScore = 0,
                TotalScore   = 0
            }).ToList();

            response.ForEach(x =>
            {
                List <ChapterInProgressDTO> chapters = chapterService.ListChaptersInProgress(userId, x.Id);
                int current = 0;
                int total   = 0;
                chapters.ForEach(y =>
                {
                    current += y.CurrentScore;
                    total   += y.TotalScore;
                });
                x.CurrentScore = current;
                x.TotalScore   = total;
            });
            return(response);
        }
Пример #2
0
 public List <ChapterInProgressDTO> ListChaptersInProgress(Guid userId, [FromBody] Guid courseId)
 {
     return(chapterService.ListChaptersInProgress(userId, courseId));
 }