/// <summary> /// 学生申请 /// </summary> /// <param name="studentId"></param> /// <param name="teacherPhone"></param> /// <returns></returns> public bool StudentApply(int studentId, string teacherPhone, int oper = 0) { var result = false; var schoolTeacher = SchoolTeacherBll.GetSchoolTeacherByPhone(teacherPhone); if (schoolTeacher != null) { using (TransactionScope scope = new TransactionScope()) { try { var apply = GetApplyByStudentId(studentId); if (apply == null || apply.Yay_Status != (int)ApplyStatusEnum.意) { CloseApplyStatus(studentId, oper); Yw_StudentApplySchool model = new Yw_StudentApplySchool(); model.Yay_OperateTime = DateTime.Now; model.Yay_Operator = studentId; model.Yay_SchoolId = schoolTeacher.Yoh_SchoolId; model.Yay_Status = (int)ApplyStatusEnum.申请; model.Yay_StudentId = studentId; model.Yay_TeacherId = schoolTeacher.Yoh_Id; model.Yay_ApplyTime = DateTime.Now; result = InsertApply(model) > 0; if (result) { scope.Complete(); } else { RollbackTran(); } } } catch (Exception ex) { RollbackTran(); throw ex; } } } return(result); }
public bool UnBindSchool(int studentId, int schoolId, int oper) { bool result = false; using (TransactionScope scope = new TransactionScope()) { try { bool updateSchool = UpdateSchool(studentId, 0); Yw_StudentApplySchool apply = new Yw_StudentApplySchool() { Yay_ApplyTime = DateTime.Now, Yay_OperateTime = DateTime.Now, Yay_Operator = oper, Yay_SchoolId = schoolId, Yay_Status = (int)ApplyStatusEnum.解绑, Yay_StudentId = studentId, Yay_TeacherId = oper }; bool insertApply = StudentApplyBll.InsertApply(apply) > 0; if (updateSchool && insertApply) { scope.Complete(); result = true; } else { RollbackTran(); result = false; } } catch (Exception ex) { RollbackTran(); throw ex; } } return(result); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> public int InsertApply(Yw_StudentApplySchool entity) { return(StudentApplySchoolRepository.Insert(entity)); }