public ActionResult Set(int cId, int type, int bId) { var classDate = classService.GetClassesInfoById(new EntityDto <long>() { Id = cId }); //班级数据 var create = new ClassDepJobEditDto(); //实例化对象Bound对象 create.ClassId = Convert.ToInt32(classDate.Id); create.ClassName = classDate.ClassesName; create.type = type; var edit = classService.GetClassesInfoForEdit(new NullableIdDto <long> { Id = create.ClassId }).ClassesInfo; //更新人数对象 switch (type) { case (int)ConfigureType.Department: if (IsChildren(cId, bId)) { return(Warn("已经有父级部门绑定了班级")); } IsParent(cId, bId); SetForDepart(edit, create, bId, cId); break; case (int)ConfigureType.Post: SetForPost(edit, create, bId, cId); break; } return(Success()); }
public ActionResult ClassesProjectSave(ClassTrainingInfoEditDto dto) { var rdto = classprojectService.GetAll().FirstOrDefault(t => t.TrainingType == dto.TrainingType && t.TypeId == dto.TypeId && t.ClassId == dto.ClassId); if (rdto != null) { return(Warn("班级中已存在项目")); } var c = classesinfoService.GetClassesInfoById(new EntityDto <long> { Id = dto.ClassId }); classprojectService.CreateClassTrainingInfoAsync(dto); var edit = classesinfoService.GetClassesInfoForEdit(new NullableIdDto <long> { Id = dto.ClassId }).ClassesInfo; switch (dto.TrainingType) { case (int)ClassProType.KS: edit.ExamCount++; break; case (int)ClassProType.WJ: edit.PollCount++; break; default: break; } //更新项目数量 classesinfoService.UpdateClassesInfoAsync(edit); return(Success("操作成功", string.Format("ClassesProjectIndex?cId={0}&cName={1}", dto.ClassId, c.ClassesName))); }
public ActionResult SetBoundCourseByType(int courseId, int typeId, int typeCaseId) { var result = new resultData(); result.status = "-1"; var courseDate = courseInfoService.GetCourseInfoById(new EntityDto <long>() { Id = courseId }); //课程数据 if (courseDate.Status != (int)CourseStatus.Pending) { return(Content(Serialize(new resultData() { status = "-2", msg = "当前课程状态为:待审核,才能添加人员" }))); } if (typeId == (int)ConfigureType.Class && courseDate != null && courseDate.Status != (int)CourseStatus.Completed && typeCaseId > 0) { var configure = configureTypeService.GetCTypeByClassIdOrType(typeCaseId, typeId); //班级的数据 var configureByCourseId = configureTypeService.GetCTypeByCourseIdOrType(courseId, typeId); //课程和班级数量 if ((configure != null && configure.Count > 0) || (configureByCourseId != null && configureByCourseId.Count > 0)) { return(Content(Serialize(new resultData() { status = "-1", msg = "班级和课程只能关联一次,不允许添加" }))); } } if (courseDate != null && typeId >= 0 && typeCaseId > 0) { var create = new CourseBoundConfigureTypeEditDto(); //实例化对象Bound对象 var boundData = configureTypeService.GetCTypeByCourseIdOrTypeId((int)courseDate.Id, typeId, typeCaseId); //绑定的数据 if (boundData == null) //如果没就增加 { create.CourseId = (int)courseDate.Id; create.CourseName = courseDate.CourseName; create.type = typeId; switch (typeId)//类型 { case (int)ConfigureType.Department: #region 部门操作 var department = departmentService.GetAllDepartmentInfos().FirstOrDefault(v => v.DepartmentId == typeCaseId); //获取部门唯一数据 if (department != null) { var createDataDUser = cbPersonnelService.GetUserDateByDepartment((int)courseDate.Id, department); foreach (var itemD in createDataDUser) //循环遍历插入 { CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto(); cbp.CourseId = (int)courseDate.Id; cbp.CourseName = courseDate.CourseName; cbp.AccountSysNo = itemD.SysNO; cbp.AccountUserName = itemD.DisplayName; cbPersonnelService.CreateCourseBoundPersonnel(cbp); } create.BusinessId = department.DepartmentId; create.BusinessName = department.DisplayName; } #endregion break; case (int)ConfigureType.Post: #region 岗位操作 var post = jobService.GetJobPostById(new EntityDto <long>() { Id = typeCaseId }); //获取唯一岗位 if (post != null) { var creatDataPUser = cbPersonnelService.GetUserDateByJobPost((int)courseDate.Id, post); foreach (var itemP in creatDataPUser) //循环遍历插入 { CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto(); cbp.CourseId = (int)courseDate.Id; cbp.CourseName = courseDate.CourseName; cbp.AccountSysNo = itemP.SysNO; cbp.AccountUserName = itemP.DisplayName; cbPersonnelService.CreateCourseBoundPersonnel(cbp); } create.BusinessId = (int)post.Id; create.BusinessName = post.Name; } #endregion break; case (int)ConfigureType.Class: #region 班级操作 var classes = classService.GetClassesInfoById(new EntityDto <long>() { Id = typeCaseId }); //获取唯一课程数据 if (classes != null) { var creatUserDate = cbPersonnelService.GetUserDateByClasses((int)courseDate.Id, classes); foreach (var itemC in creatUserDate) //循环遍历插入 { CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto(); cbp.CourseId = (int)courseDate.Id; cbp.CourseName = courseDate.CourseName; cbp.AccountSysNo = itemC.SysNO; cbp.AccountUserName = itemC.DisplayName; cbPersonnelService.CreateCourseBoundPersonnel(cbp); } create.BusinessId = (int)classes.Id; create.BusinessName = classes.ClassesName; } #endregion break; default: break; } configureTypeService.CreateCourseBoundConfigureType(create); result.msg = ""; } else { result.msg = boundData.BusinessName; } result.status = "0"; } return(Content(Serialize(result))); }