public Yw_CourseLesson GetLesson(int lessonId) { return(LessonServer.Select(lessonId)); }
/// <summary> /// 更新课程状态 /// </summary> /// <param name="lessonid">课程id</param> /// <param name="status">课程状态</param> /// <param name="editor">操作人</param> /// <returns>返回课时操作流程id(如果为0表示不能修改)</returns> public int UpdateLessonStatus(int lessonid, LessonStatusEnum status, int editor) { var lesson = LessonServer.Select(lessonid); if (lesson != null) { LessonStatusEnum oldStatus = (LessonStatusEnum)lesson.Ycl_Status; LessonStatusActionEnum action = 0;//枚举值定义为0表示不能修改 //未编辑只能改为制作中,动作为编辑 if (oldStatus == LessonStatusEnum.未编辑 && status == LessonStatusEnum.制作中) { action = LessonStatusActionEnum.编辑; lesson.Ycl_Producer = editor;//记录制作人 } //制作中只能改为待审批,动作为完成编辑 else if (oldStatus == LessonStatusEnum.制作中 && status == LessonStatusEnum.待审批) { action = LessonStatusActionEnum.完成编辑; lesson.Ycl_Producer = editor; //记录制作人 lesson.Ycl_Approver = 0; //清空审批人 } //待审批只能改为审批中,动作为审批 else if (oldStatus == LessonStatusEnum.待审批 && status == LessonStatusEnum.审批中) { action = LessonStatusActionEnum.审批; } //审批中能改为合格与不合格,动作为审批 else if (oldStatus == LessonStatusEnum.审批中 && (status == LessonStatusEnum.合格 || status == LessonStatusEnum.合格)) { action = LessonStatusActionEnum.审批; lesson.Ycl_Approver = editor; //记录审批人 if (status == LessonStatusEnum.合格) //如果是合格状态,就会修改题目数据 { List <int> questionids = new LessonUnitBll().SelectLessonQuestions(lesson.Ycl_Id); //查询出本课时中所有的题目 new CourseSubjectRelBll().AddSubjectToLesson(lesson, questionids); //将题目id添加到课程题目对应表 } } //合格和不合格只能改为制作中,动作重新编辑 else if ((oldStatus == LessonStatusEnum.合格 || oldStatus == LessonStatusEnum.合格) && status == LessonStatusEnum.制作中) { action = LessonStatusActionEnum.重新编辑; lesson.Ycl_Producer = editor; //记录制作人 lesson.Ycl_Approver = 0; //清空审批人 } if ((int)action != 0)//如果枚举值不为0 则表示可以进行修改 { //修改课时状态并更新 lesson.Ycl_Status = (int)status; lesson.Ycl_Editor = editor; lesson.Ycl_UpdateTime = DateTime.Now; LessonServer.Update(lesson); //创建审批对象 Yw_CourseLessonProcess lessonPorcess = new Yw_CourseLessonProcess { Ylp_CourseId = lesson.Ycl_CourseId, Ylp_LessonId = lesson.Ycl_Id, Ylp_Status = lesson.Ycl_Status, Ylp_Action = (int)action, Ylp_CreateTime = DateTime.Now, Ylp_Operator = editor, Ylp_Remark = $"课程“{lesson.Ycl_Name}”状态从 {oldStatus} 改为 {status}" }; //添加课时操作流程 LessonProcessServer.Insert(lessonPorcess); //返回课时操作流程id return(lessonPorcess.Ylp_Id); } } return(0); }