示例#1
0
        protected virtual void ProcessModifiedCourses(
            ICollection <EntityPair <Course, TCourseParseModel> > modifiedCourses, List <AuthorResolve> authorResolves)
        {
            foreach (var coursePair in modifiedCourses)
            {
                var courseBackup = CatalogBackupProcessor.CourseBackupCreator.ApplayChanges(UpdateEvent.Id,
                                                                                            coursePair.DbEntity, coursePair.ParseModelEntity);

                // detect authors changes
                var courseAuthorBackups = DetectCourseAuthorChanges(coursePair, authorResolves);
                if (courseAuthorBackups.Any())
                {
                    if (courseBackup == null)
                    {
                        courseBackup = new CourseBackup
                        {
                            UpdateEventId       = UpdateEvent.Id,
                            CourseId            = coursePair.DbEntity.Id,
                            CourseAuthorBackups = courseAuthorBackups
                        };
                    }
                    else
                    {
                        courseBackup.CourseAuthorBackups = courseAuthorBackups;
                    }
                }

                AddUpdates(EntityType.Course, coursePair.DbEntity.Id, OperationType.Modify, courseBackup);
            }
        }
示例#2
0
        protected virtual void ProcessCategoryAndAuthorsChangesForUnmodifiedCourses(
            ICollection <EntityPair <Course, TCourseParseModel> > unmodifiedCourses, List <AuthorResolve> authorResolves)
        {
            foreach (var coursePair in unmodifiedCourses)
            {
                CourseBackup courseBackup = null;

                // detect category changes
                if (IsMovedToAnotherCategory(coursePair))
                {
                    courseBackup = new CourseBackup
                    {
                        UpdateEventId = UpdateEvent.Id,
                        CategoryId    = coursePair.DbEntity.CategoryId
                    };

                    AssignCategoryIdToDbEntity(coursePair);
                }

                // detect authors changes
                var courseAuthorBackups = DetectCourseAuthorChanges(coursePair, authorResolves);

                if (courseAuthorBackups.Any())
                {
                    if (courseBackup == null)
                    {
                        courseBackup = new CourseBackup
                        {
                            UpdateEventId       = UpdateEvent.Id,
                            CourseId            = coursePair.DbEntity.Id,
                            CourseAuthorBackups = courseAuthorBackups
                        };
                    }
                    else
                    {
                        courseBackup.CourseAuthorBackups = courseAuthorBackups;
                    }
                }

                // log if any changes
                if (courseBackup != null)
                {
                    AddUpdates(EntityType.Course, coursePair.DbEntity.Id, OperationType.Modify, courseBackup);
                }
            }
        }