Esempio n. 1
0
        /// <summary>
        /// 实例化<see cref="StudingRecord"/>对象实例
        /// </summary>
        /// <param name="studentId">学员ID</param>
        /// <param name="chapter">学习的课程章节</param>
        public StudingRecord(long studentId, Data.Entity.Chapter chapter)
        {
            StudentId = studentId;
            Chapter   = chapter;

            InitData();
        }
Esempio n. 2
0
        /// <summary>
        /// 保存章节
        /// </summary>
        /// <returns></returns>
        public bool Save()
        {
            ThrowExceptionIfValidateFailure();

            Data.Entity.Chapter chapter = new Data.Entity.Chapter
            {
                ChapterId  = ID,
                Content    = Content,
                Count      = Count,
                CourseId   = CourseId,
                CreateTime = DateTime.Now,
                ParentId   = ParentId,
                ParentPath = ChapterTools.CreateParentPath(ParentChapter, ID),
                Status     = Status,
                Title      = Title,
                Video      = Video,
                IsLeaf     = true
            };

            bool success = ChapterAccessor.Insert(chapter);

            if (success)
            {
                ComputeStudyProgress(CourseId);
            }

            return(success);
        }
Esempio n. 3
0
 public ChapterManage(Data.Entity.Chapter chapter)
 {
     if (chapter != null)
     {
         ID      = chapter.ChapterId;
         Chapter = chapter;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 实例化<see cref="StudingRecord"/>对象实例
        /// </summary>
        /// <param name="studentId">学员ID</param>
        /// <param name="chapterId">学习的课程章节ID</param>
        public StudingRecord(long studentId, long chapterId)
        {
            StudentId = studentId;

            //获取章节信息
            Chapter = ChapterAccessor.Get(chapterId);

            InitData();
        }
Esempio n. 5
0
        /// <summary>
        /// 修改章节信息
        /// </summary>
        /// <param name="state">编辑后的数据状态</param>
        /// <returns></returns>
        public bool Modify(ChapterModifyState state)
        {
            if (state == null)
            {
                return(false);
            }

            Data.Entity.Chapter parent = null;
            if (state.ParentId > 0)
            {
                parent = ChapterAccessor.Get(state.ParentId);
            }

            ThrowExceptionIfValidateFailure(() =>
            {
                if (CanModify())
                {
                    //所属课程
                    if (!CourseAccessor.Exists(state.CourseId))
                    {
                        AddBrokenRule(ChapterManageFailureRule.COURSE_NOT_EXISTS);
                    }

                    //有关联父章节时,父章节不存在
                    if (state.ParentId > 0 && parent == null)
                    {
                        AddBrokenRule(ChapterManageFailureRule.PAREND_NOT_EXISTS);
                    }

                    //标题不能为空
                    if (string.IsNullOrWhiteSpace(state.Title))
                    {
                        AddBrokenRule(ChapterManageFailureRule.TITLE_CANNOT_EMPTY);
                    }

                    //内容不能为空
                    if (string.IsNullOrWhiteSpace(state.Content))
                    {
                        AddBrokenRule(ChapterManageFailureRule.CONTENT_CANNOT_EMPTY);
                    }
                }
                else
                {
                    AddBrokenRule(ChapterManageFailureRule.CANNOT_MODIFY);
                }
            });

            bool success = ChapterAccessor.Update(
                ID,
                state.CourseId,
                state.ParentId,
                ChapterTools.CreateParentPath(parent, ID),
                state.Title,
                state.Content,
                state.Video,
                state.Status);

            if (success && (Chapter.CourseId != state.CourseId || Chapter.Status != state.Status))
            {
                ComputeStudyProgress(state.CourseId);
            }

            return(success);
        }
Esempio n. 6
0
 public ChapterManage(long chapterId)
 {
     ID      = chapterId;
     Chapter = ChapterAccessor.Get(chapterId);
 }
Esempio n. 7
0
 /// <summary>
 /// 实例化<see cref="CourseStudy"/>对象
 /// </summary>
 /// <param name="chapter">课程章节</param>
 /// <param name="studentId">学员ID</param>
 public CourseStudy(long studentId, Data.Entity.Chapter chapter)
 {
     Chapter = chapter;
     Student = UsersAccessor.Get(studentId);
 }
Esempio n. 8
0
 /// <summary>
 /// 实例化<see cref="CourseStudy"/>对象
 /// </summary>
 /// <param name="chapter">课程章节</param>
 /// <param name="student">学员信息</param>
 public CourseStudy(Data.Entity.Users student, Data.Entity.Chapter chapter)
 {
     Chapter = chapter;
     Student = student;
 }
Esempio n. 9
0
 /// <summary>
 /// 实例化<see cref="CourseStudy"/>对象
 /// </summary>
 /// <param name="studentId">学员ID</param>
 /// <param name="chapterId">学习的课程章节ID</param>
 public CourseStudy(long studentId, long chapterId)
 {
     Chapter = ChapterAccessor.Get(chapterId);
     Student = UsersAccessor.Get(studentId);
 }