Example #1
0
        public void DeleteChapter(long chapterId)
        {
            Chapter chapter = new ChapterBll(new HengNuoWangDBContext()).GetChapter(chapterId);
            if (chapter == null)
            {
                string.Format("不存在指定chapterId:{0}的章节", chapterId).ThrowException();
            }
            Chapter chptr = new Chapter()
            {
                Id = chapter.Id,
                SeqNo = chapter.SeqNo,
                CourseId = chapter.CourseId,
            };
            int row = _dal.DeleteChapter(chptr);

            if (row <= 0)
            {
                string.Format("删除章节chapterId:{0}失败", chapter.Id).ThrowException();
            }
        }
Example #2
0
 public ActionResult Delete(long id)
 {
     // 检查参数
     Chapter chapter = new ChapterBll(new HengNuoWangDBContext()).GetChapter(chapterId: id);
     if (chapter == null)
     {
         ViewBag.error = "章节不存在";
         return View("Error");
     }
     int number = _segmentBll.GetSegmentNumberOfChapter(chapter.Id);
     if (number > 0)
     {
         ViewBag.error = "章节下还有段落,不能删除";
         return View("Error");
     }
     // 删除章节
     _chapterBll.DeleteChapter(chapter.Id);
     // 记录日志
     string log = string.Format("删除章节{0}:‘{1}’", chapter.Id, chapter.Name);
     AdminOperationLogBll.AddAdminOperationLog(AdminUserId, log);
     // 跳转到所属课程列表页面
     string url = string.Format("/Chapter/List/{0}", chapter.CourseId);
     return new RedirectResult(url);
 }
Example #3
0
        public JsonResult Edit(long id)
        {
            Segment oldSegment = new SegmentBll(new HengNuoWangDBContext()).GetSegment(segmentId: id);
            if (oldSegment == null)
            {
                return JsonHelper.GetJsonResult(_ERROR, "段落不存在");
            }
            Chapter oldChapter = new ChapterBll(new HengNuoWangDBContext()).GetChapter(oldSegment.ChapterId);

            string segmentName = Request["name"];
            long seqNo, chptrId;
            string videoCode = Request["vidcd"];
            string note = Request["note"];
            Chapter newChapter;
            if (CommonHelper.IsNullOrEmptyOrWhiteSpace(segmentName, videoCode) ||
                segmentName.Length > 50 ||
                !long.TryParse(Request["seqno"], out seqNo) || seqNo <= 0 ||
                !long.TryParse(Request["chptrid"], out chptrId) ||
                (newChapter = _chapterBll.GetChapter(chptrId)) == null)
            {
                return JsonHelper.GetJsonResult(_ERROR, "段落名称 或 序号 或 视频代码 错误");
            }
            Segment sgmnt = new SegmentBll(new HengNuoWangDBContext()).GetSegment(segmentName);
            if (sgmnt != null && sgmnt.Id != oldSegment.Id)
            {
                return JsonHelper.GetJsonResult(_ERROR, "段落名称已经存在");
            }
            // 更新
            Segment newSegment = new Segment()
            {
                Id = oldSegment.Id,
                Name = segmentName,
                SeqNo = seqNo,
                VideoCode = videoCode,
                Note = note,
                ChapterId = newChapter.Id,
            };
            _segmentBll.UpdateSegment(oldSegment, newSegment);
            // 记录日志
            string log = string.Format("更新段落‘{0}’:【名称‘{1}=>{2}’;所属章节‘{3}=>{4}’;序号‘{5}=>{6}’】",
                newSegment.Id, oldSegment.Name, newSegment.Name,
                oldChapter.Name, newChapter.Name, oldSegment.SeqNo, newSegment.SeqNo);
            AdminOperationLogBll.AddAdminOperationLog(AdminUserId, log);
            string url = string.Format("/Segment/List/{0}", newSegment.ChapterId);
            return JsonHelper.GetJsonResult(_OK, "更新成功", url);
        }
Example #4
0
 public JsonResult Edit(long id)
 {
     // 检查请求
     string chapterName = Request["name"];
     long seqNo, courseId;
     Chapter oldChapter;
     if (CommonHelper.IsNullOrEmptyOrWhiteSpace(chapterName) ||
         chapterName.Length > 50 ||
         !long.TryParse(Request["seqno"], out seqNo) ||
         seqNo <= 0 ||
         !long.TryParse(Request["crsid"], out courseId) ||
         (oldChapter = new ChapterBll(new HengNuoWangDBContext()).GetChapter(chapterId: id)) == null)
     {
         return JsonHelper.GetJsonResult(_ERROR, "章节名 或 序号 错误");
     }
     Chapter newChapter = new Chapter()
     {
         Id = oldChapter.Id,
         Name = chapterName,
         SeqNo = seqNo,
         CourseId = oldChapter.CourseId,
     };
     if (oldChapter.Name == newChapter.Name && oldChapter.SeqNo == newChapter.SeqNo)
     {
         return JsonHelper.GetJsonResult(_ERROR, "章节名和序号都没有变化");
     }
     // 更新
     _chapterBll.UpdateChapter(oldChapter, newChapter);
     // 记录日志
     string log = string.Format("更新章节‘{0}’:章节名【{1}=>{2}】;段落序号【{3}=>{4}】;所属课程【{5}=>{6}】",
         oldChapter.Id, oldChapter.Name, newChapter.Name,
         oldChapter.SeqNo, newChapter.SeqNo, oldChapter.CourseId, newChapter.CourseId);
     AdminOperationLogBll.AddAdminOperationLog(AdminUserId, log);
     // 跳转列表
     string url = string.Format("/Chapter/List/{0}", oldChapter.CourseId);
     return JsonHelper.GetJsonResult(_OK, "更新章节成功", url);
 }