Example #1
0
        public OperationResultVo GetMyCourses(Guid currentUserId)
        {
            try
            {
                StudyCoursesOfUserVo courses = studyDomainService.GetCoursesForUserId(currentUserId);

                List <StudyCourseListItemVo> finalList = new List <StudyCourseListItemVo>();

                foreach (UserCourseVo course in courses.Courses)
                {
                    if (!finalList.Any(x => x.Id == course.CourseId))
                    {
                        StudyCourseListItemVo vm = new StudyCourseListItemVo
                        {
                            Id   = course.CourseId,
                            Name = course.CourseName
                        };

                        finalList.Add(vm);
                    }
                }

                return(new OperationResultListVo <StudyCourseListItemVo>(finalList));
            }
            catch (Exception ex)
            {
                return(new OperationResultVo(ex.Message));
            }
        }
Example #2
0
        public async Task <OperationResultVo> GetMyCourses(Guid currentUserId)
        {
            try
            {
                StudyCoursesOfUserVo courses = await mediator.Query <GetCoursesForUserIdQuery, StudyCoursesOfUserVo>(new GetCoursesForUserIdQuery(currentUserId));

                List <StudyCourseListItemVo> finalList = new List <StudyCourseListItemVo>();

                foreach (UserCourseVo course in courses.Courses)
                {
                    if (!finalList.Any(x => x.Id == course.CourseId))
                    {
                        StudyCourseListItemVo vm = new StudyCourseListItemVo
                        {
                            Id   = course.CourseId,
                            Name = course.CourseName
                        };

                        finalList.Add(vm);
                    }
                }

                return(new OperationResultListVo <StudyCourseListItemVo>(finalList));
            }
            catch (Exception ex)
            {
                return(new OperationResultVo(ex.Message));
            }
        }
Example #3
0
        public StudyCoursesOfUserVo GetCoursesForUserId(Guid userId)
        {
            List <UserCourseVo> objs = studyCourseRepository.Get().Where(x => x.Members.Any(y => y.UserId == userId)).Select(x => new UserCourseVo
            {
                CourseId   = x.Id,
                CourseName = x.Name
            }).ToList();

            StudyCoursesOfUserVo result = new StudyCoursesOfUserVo
            {
                UserId = userId
            };

            if (objs.Any())
            {
                result.Courses = objs;
            }

            return(result);
        }