Ejemplo n.º 1
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));
            }
        }
Ejemplo n.º 2
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));
            }
        }