/// <summary> /// 根据单元(讲义)id查询单元(讲义)信息 /// </summary> /// <param name="unitId"></param> /// <returns></returns> public DtoLessonUnit SelectUnit(int unitId, int processId) { DtoLessonUnit unit = new DtoLessonUnit(); var unitInfo = LessonServer.SelectUnit(unitId); var unitSteps = (Yw_LessonUnitStepActions)UnitStepFactory.Create(UnitServer.SelectSteps(unitId)); if (unitInfo != null) { unit.Id = unitInfo.Ycu_Id; unit.CourseId = unitInfo.Ycu_CourseId; unit.LessonId = unitInfo.Ycu_LessonId; unit.Index = unitInfo.Ycu_Index; unit.Name = unitInfo.Ycu_Name; unit.Screenshot = unitInfo.Ycu_Screenshot; unit.Status = unitInfo.Ycu_Status; unit.Creator = unitInfo.Ycu_Creator; unit.CreateTime = unitInfo.Ycu_CreateTime; unit.Editor = unitInfo.Ycu_Editor; unit.UpdateTime = unitInfo.Ycu_UpdateTime; if (unitSteps != null) { unit.Steps = unitSteps.Steps; } if (processId != 0) //如果有审批id { var approve = ApproveServer.SelectByUnitIdAndProcessID(unitId, processId); //获取最后一个审批意见 if (approve != null) //如果审批意见不为空,添加审批内容 { unit.Approve = approve.Yup_Remark; unit.ApproveStatus = approve.Yup_Status; } } } return(unit); }
/// <summary> /// 修改单元讲义数据 /// </summary> /// <param name="unit"></param> /// <returns></returns> public void Update(DtoLessonUnit unit) { var lessonUnit = LessonServer.SelectUnit(unit.Id); var unitSteps = (Yw_LessonUnitStepActions)UnitStepFactory.Create(UnitServer.SelectSteps(unit.Id)); lessonUnit.Ycu_Name = unit.Name; lessonUnit.Ycu_Screenshot = unit.Screenshot; lessonUnit.Ycu_Editor = unit.Editor; lessonUnit.Ycu_Index = unit.Index; if (unit.Steps != null) { unitSteps.Yls_UnitId = lessonUnit.Ycu_Id; unitSteps.Yls_UnitIndex = unit.Index; unitSteps.Steps = unit.Steps; unitSteps.Yls_Coins = unit.Coins; unitSteps.Yls_SubjectIds = GetLessonQuestionIdStr(unit.Steps); } LessonServer.UpdateUnits(lessonUnit); UnitServer.UpdateSteps(unitSteps); }