public virtual async Task DeleteCourseLesson(CourseLesson lesson)
        {
            await _courseLessonService.Delete(lesson);

            //activity log
            await _customerActivityService.InsertActivity("DeleteCourseLesson", lesson.Id, _localizationService.GetResource("ActivityLog.DeleteCourseLesson"), lesson.Name);
        }
Beispiel #2
0
        public async Task ReleaseLesson(Course course, CourseLesson lesson)
        {
            var index = course.LessonSchedule.FindIndex(x => x.isBusy && x.StartLessonTime.Hour == lesson.StartLessonTime.Hour && x.StartLessonTime.Minute == lesson.StartLessonTime.Minute && x.WeekDay == lesson.WeekDay);

            course.LessonSchedule[index].BusyExpireDate = new DateTime(1, 1, 1);
            course.LessonSchedule[index].isBusy         = false;

            _context.Update(course);
            await _context.SaveChangesAsync();
        }
Beispiel #3
0
        public virtual async Task Delete(CourseLesson courseLesson)
        {
            if (courseLesson == null)
            {
                throw new ArgumentNullException(nameof(courseLesson));
            }

            await _courseLessonRepository.DeleteAsync(courseLesson);

            //event notification
            await _mediator.EntityDeleted(courseLesson);
        }
Beispiel #4
0
        public async Task ReleaseLesson(Course course, CourseLesson lesson)
        {
            using (var context = ContextFactory.CreateDbContext(ConnectionString))
            {
                var index = course.LessonSchedule.FindIndex(x => x.isBusy && x.StartLessonTime.Hour == lesson.StartLessonTime.Hour && x.StartLessonTime.Minute == lesson.StartLessonTime.Minute && x.WeekDay == lesson.WeekDay);
                course.LessonSchedule[index].BusyExpireDate = new DateTime(1, 1, 1);
                course.LessonSchedule[index].isBusy         = false;

                context.Update(course);
                await context.SaveChangesAsync();
            }
        }
Beispiel #5
0
        public virtual async Task <CourseLesson> Insert(CourseLesson courseLesson)
        {
            if (courseLesson == null)
            {
                throw new ArgumentNullException(nameof(courseLesson));
            }

            await _courseLessonRepository.InsertAsync(courseLesson);

            //event notification
            await _mediator.EntityInserted(courseLesson);

            return(courseLesson);
        }
        public virtual async Task <CourseLesson> Update(CourseLesson courseLesson)
        {
            if (courseLesson == null)
            {
                throw new ArgumentNullException("courseLesson");
            }

            await _courseLessonRepository.UpdateAsync(courseLesson);

            //event notification
            await _mediator.EntityUpdated(courseLesson);

            return(courseLesson);
        }
Beispiel #7
0
        public void LoadDocumentTest()
        {
            using (var store = GetDocumentStore())
            {
                store.ExecuteIndex(new CoursesByCourseLesson());
                using (var session = store.OpenSession())
                {
                    var lesson1 = new Lesson();
                    session.Store(lesson1);
                    var lesson2 = new Lesson();
                    session.Store(lesson2);
                    var courseLesson1 = new CourseLesson {
                        LessonId = lesson1.Id
                    };
                    var courseLesson2 = new CourseLesson {
                        LessonId = lesson2.Id
                    };

                    var course = new Course();
                    course.Lessons.Add(courseLesson1);
                    course.Lessons.Add(courseLesson2);

                    session.Store(course);
                    session.SaveChanges();
                }

                WaitForIndexing(store);

                RavenTestHelper.AssertNoIndexErrors(store);

                using (var session = store.OpenSession())
                {
                    var query = session.Query <CourseLessonProjection, CoursesByCourseLesson>()
                                .Where(x => x.CourseId == "courses/1-A")
                                .ProjectInto <CourseLessonProjection>()
                                .ToList();

                    Assert.Equal(2, query.Count);
                    Assert.Equal(2, query.Count(x => x.CourseId == "courses/1-A"));
                    Assert.Equal(1, query.Count(x => x.LessonId == "lessons/1-A"));
                    Assert.Equal(1, query.Count(x => x.LessonId == "lessons/2-A"));
                    Assert.Equal(1, query.Count(x => x.Index == 0));
                    Assert.Equal(1, query.Count(x => x.Index == 1));
                }
            }
        }
Beispiel #8
0
        public virtual async Task Approved(Course course, CourseLesson lesson, Customer customer)
        {
            var action = await _courseActionService.GetCourseAction(customer.Id, lesson.Id);

            if (action == null)
            {
                await _courseActionService.InsertAsync(new CourseAction()
                {
                    CustomerId = customer.Id,
                    CourseId   = course.Id,
                    LessonId   = lesson.Id,
                    Finished   = true
                });
            }
            else
            {
                action.Finished = true;
                await _courseActionService.Update(action);
            }
        }
Beispiel #9
0
        public virtual async Task <LessonModel> PrepareLessonModel(Course course, CourseLesson lesson)
        {
            var model = new LessonModel();

            var modelCourse = course.ToModel(_workContext.WorkingLanguage);

            model.Id                = lesson.Id;
            model.CourseId          = modelCourse.Id;
            model.CourseDescription = modelCourse.Description;
            model.CourseName        = modelCourse.Name;
            model.CourseSeName      = modelCourse.SeName;
            model.MetaDescription   = modelCourse.MetaDescription;
            model.MetaKeywords      = model.MetaKeywords;
            model.MetaTitle         = model.MetaTitle;
            model.Name              = lesson.Name;
            model.ShortDescription  = lesson.ShortDescription;
            model.Description       = lesson.Description;
            model.GenericAttributes = lesson.GenericAttributes;
            model.CourseLevel       = (await _courseLevelService.GetById(course.LevelId))?.Name;

            //prepare picture
            var picture = await _pictureService.GetPictureById(lesson.PictureId);

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

            model.Approved = await _courseActionService.CustomerLessonCompleted(_workContext.CurrentCustomer.Id, lesson.Id);

            if (!string.IsNullOrEmpty(lesson.AttachmentId))
            {
                model.DownloadFile = true;
            }

            if (!string.IsNullOrEmpty(lesson.VideoFile))
            {
                model.VideoFile = true;
            }

            return(model);
        }
        public virtual async Task <CourseLesson> UpdateCourseLessonModel(CourseLesson lesson, CourseLessonModel model)
        {
            string prevPictureId = lesson.PictureId;

            lesson = model.ToEntity(lesson);
            await _courseLessonService.Update(lesson);

            //delete an old picture (if deleted or updated)
            if (!string.IsNullOrEmpty(prevPictureId) && prevPictureId != lesson.PictureId)
            {
                var prevPicture = await _pictureService.GetPictureById(prevPictureId);

                if (prevPicture != null)
                {
                    await _pictureService.DeletePicture(prevPicture);
                }
            }

            //activity log
            await _customerActivityService.InsertActivity("EditCourseLesson", lesson.Id, _localizationService.GetResource("ActivityLog.EditLessonCourse"), lesson.Name);

            return(lesson);
        }
 public static CourseLessonModel ToModel(this CourseLesson entity)
 {
     return(entity.MapTo <CourseLesson, CourseLessonModel>());
 }
 public static CourseLesson ToEntity(this CourseLessonModel model, CourseLesson destination)
 {
     return(model.MapTo(destination));
 }