示例#1
0
        public async Task <IActionResult> Subjects(DataSourceRequest command, string courseId)
        {
            var subjectModel = (await _courseSubjectService.GetByCourseId(courseId))
                               .Select(x => x.ToModel());

            var gridModel = new DataSourceResult {
                Data  = subjectModel,
                Total = subjectModel.Count()
            };

            return(Json(gridModel));
        }
示例#2
0
        public virtual async Task <CourseModel> PrepareCourseModel(Course course)
        {
            var model = course.ToModel(_workContext.WorkingLanguage);

            model.Level = (await _courseLevelService.GetById(course.LevelId))?.Name;

            var pictureSize = _mediaSettings.CourseThumbPictureSize;
            var picture     = await _pictureService.GetPictureById(course.PictureId);

            model.PictureUrl = await _pictureService.GetPictureUrl(picture, pictureSize);

            var subjects = await _courseSubjectService.GetByCourseId(course.Id);

            foreach (var item in subjects)
            {
                model.Subjects.Add(new CourseModel.Subject()
                {
                    Id           = item.Id,
                    Name         = item.Name,
                    DisplayOrder = item.DisplayOrder
                });
            }

            var lessonPictureSize = _mediaSettings.LessonThumbPictureSize;
            var lessons           = await _courseLessonService.GetByCourseId(course.Id);

            foreach (var item in lessons.Where(x => x.Published))
            {
                var lessonPicture = await _pictureService.GetPictureById(item.PictureId);

                var pictureUrl = await _pictureService.GetPictureUrl(lessonPicture, lessonPictureSize);

                var approved = await _courseActionService.CustomerLessonCompleted(_workContext.CurrentCustomer.Id, item.Id);

                model.Lessons.Add(new CourseModel.Lesson()
                {
                    Id               = item.Id,
                    SubjectId        = item.SubjectId,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    DisplayOrder     = item.DisplayOrder,
                    PictureUrl       = pictureUrl,
                    Approved         = approved
                });
            }
            model.Approved = !model.Lessons.Any(x => !x.Approved);
            return(model);
        }
        public virtual async Task <CourseLessonModel> PrepareCourseLessonModel(string courseId, CourseLessonModel model = null)
        {
            if (model == null)
            {
                model           = new CourseLessonModel();
                model.Published = true;
            }
            model.CourseId = courseId;

            foreach (var item in await _courseSubjectService.GetByCourseId(courseId))
            {
                model.AvailableSubjects.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem()
                {
                    Text  = item.Name,
                    Value = item.Id
                });
            }

            return(model);
        }
示例#4
0
        public async Task <CourseModel> Handle(GetCourse request, CancellationToken cancellationToken)
        {
            var model = request.Course.ToModel(request.Language);

            model.Level = (await _courseLevelService.GetById(request.Course.LevelId))?.Name;

            model.PictureUrl = await _pictureService.GetPictureUrl(request.Course.PictureId, _mediaSettings.CourseThumbPictureSize);

            var subjects = await _courseSubjectService.GetByCourseId(request.Course.Id);

            foreach (var item in subjects)
            {
                model.Subjects.Add(new CourseModel.Subject()
                {
                    Id           = item.Id,
                    Name         = item.Name,
                    DisplayOrder = item.DisplayOrder
                });
            }
            var lessons = await _courseLessonService.GetByCourseId(request.Course.Id);

            foreach (var item in lessons.Where(x => x.Published))
            {
                var pictureUrl = await _pictureService.GetPictureUrl(item.PictureId, _mediaSettings.LessonThumbPictureSize);

                var approved = await _courseActionService.CustomerLessonCompleted(request.Customer.Id, item.Id);

                model.Lessons.Add(new CourseModel.Lesson()
                {
                    Id               = item.Id,
                    SubjectId        = item.SubjectId,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    DisplayOrder     = item.DisplayOrder,
                    PictureUrl       = pictureUrl,
                    Approved         = approved
                });
            }
            model.Approved = !model.Lessons.Any(x => !x.Approved);
            return(model);
        }