예제 #1
0
        public GetCourseDetailRespond GetCourseDetail(string id)
        {
            var isArgumentValid = !string.IsNullOrEmpty(id);
            if (!isArgumentValid) return null;

            var selectedCourse = _repo.GetCourseCatalogById(id);
            if (selectedCourse == null) return null;

            var relatedCourses = GetRelatedCourses(selectedCourse.GroupName)
                .Where(it => it.id != id)
                .Select(it=>new GetCourseDetailRespond.RelatedCourse
                {
                    CourseId = it.id,
                    Name = it.Name
                }).ToList();

            var result = new GetCourseDetailRespond
            {
                id = selectedCourse.id,
                Grade = selectedCourse.Grade,
                GroupName = selectedCourse.GroupName,
                CreatedDate = selectedCourse.CreatedDate,
                Description = selectedCourse.FullDescription,
                DescriptionImageUrl = selectedCourse.DescriptionImageUrl,
                ImageUrl = selectedCourse.FullImageUrl,
                Name = selectedCourse.Name,
                Price = selectedCourse.Price,
                Title = selectedCourse.Title,
                TotalWeeks = selectedCourse.Semesters.SelectMany(it => it.Units).SelectMany(it=>it.Lessons).Count(),
                RelatedCourses = relatedCourses,
                Semesters = selectedCourse.Semesters.Select(semester => new GetCourseDetailRespond.Semester
                {
                    Description = semester.Description,
                    Name = semester.Name,
                    Title = semester.Title,
                    TotalWeeks = semester.Units.SelectMany(unit => unit.Lessons).Count(),
                    Units = semester.Units.Select(unit => new GetCourseDetailRespond.Unit
                    {
                        Description = unit.Description,
                        Title = unit.Title,
                        TotalWeeks = unit.Lessons.Count(),
                        UnitNo = unit.Order,
                        Lessons = unit.Lessons.Select(lesson => new GetCourseDetailRespond.Lesson
                        {
                            id = lesson.id,
                            Order = lesson.Order,
                            Contents = lesson.Contents.Select(it=>new GetCourseDetailRespond.LessonContent
                            {
                                Description = it.Description,
                                ImageUrl = it.ImageUrl
                            }).ToList()
                        }).ToList()
                    }).ToList()
                }).ToList()
            };
            return result;
        }
예제 #2
0
        public GetCourseDetailRespond GetCourseDetail(string id)
        {
            var isArgumentValid = !string.IsNullOrEmpty(id);
            if (!isArgumentValid) return null;

            var selectedCourse = _repo.GetCourseCatalogById(id);
            var isCourseValid = selectedCourse != null && !selectedCourse.DeletedDate.HasValue;
            if (!isCourseValid) return null;

            var relatedCourses = GetRelatedCourses(selectedCourse.GroupName)
                .Where(it => it.id != id)
                .Select(it => new GetCourseDetailRespond.RelatedCourse
                {
                    CourseId = it.id,
                    Name = it.Name
                }).ToList();

            var result = new GetCourseDetailRespond
            {
                id = selectedCourse.id,
                GroupName = selectedCourse.GroupName,
                Grade = selectedCourse.Grade,
                SideName = selectedCourse.SideName,
                PriceUSD = selectedCourse.PriceUSD,
                Series = selectedCourse.Series,
                Title = selectedCourse.Title,
                FullDescription = selectedCourse.FullDescription,
                DescriptionImageUrl = selectedCourse.DescriptionImageUrl,
                TotalWeeks = selectedCourse.TotalWeeks,
                CreatedDate = selectedCourse.CreatedDate,
                RelatedCourses = relatedCourses,
                Semesters = selectedCourse.Semesters.Select(semester => new GetCourseDetailRespond.Semester
                {
                    Name = semester.Name,
                    Title = semester.Title,
                    Description = semester.Description,
                    TotalWeeks = semester.TotalWeeks,
                    Units = semester.Units.Select(unit => new GetCourseDetailRespond.Unit
                    {
                        UnitNo = unit.Order,
                        Title = unit.Title,
                        Description = unit.Description,
                        TotalWeeks = unit.TotalWeeks,
                        Lessons = unit.Lessons.Select(lesson => new GetCourseDetailRespond.Lesson
                        {
                            id = lesson.id,
                            Order = lesson.Order,
                            Contents = lesson.Contents.Select(it => new GetCourseDetailRespond.LessonContent
                            {
                                ContentUrl = it.ContentURL,
                                Description = it.Description,
                                ImageUrl = it.ImageUrl,
                                IsPreviewable = it.IsPreviewable,
                            })
                        })
                    })
                }).ToList()
            };
            return result;
        }