public JsonResult FirstRegTPInfo(FirstInterviewTPModel ajaxData) { StudentInfoEntity studentInfo = repository.StudentsInfo.SingleOrDefault(s=>s.StudentID == ajaxData.StudentInfo.StudentID); StudentTPInfoEntity studentTPInfo = ajaxData.StudentTPInfo; studentTPInfo.StudentID = studentInfo.StudentID; repository.SaveStudentTPInfo(studentTPInfo); ExamResultEntity _TFIELTSResult = ajaxData.TFIELTSResult; if (_TFIELTSResult != null) { if (_TFIELTSResult.ResultID == Guid.Empty) _TFIELTSResult.ResultID = Guid.NewGuid(); _TFIELTSResult.StudentID = studentInfo.StudentID; repository.SaveExamResult(_TFIELTSResult); } ExamResultEntity _SATSSATResult = ajaxData.SATSSATResult; ExamResultSATSSATEntity _SATSSATResultDetail = ajaxData.SATSSATResultDetail; if (_SATSSATResult != null) { if (_SATSSATResultDetail != null) { if (_SATSSATResultDetail.ExamID == Guid.Empty) _SATSSATResultDetail.ExamID = Guid.NewGuid(); repository.SaveExamResultSATSSAT(_SATSSATResultDetail); _SATSSATResult.ExamID = _SATSSATResultDetail.ExamID; } else { _SATSSATResult.ExamID = Guid.Empty; } if (_SATSSATResult.ResultID == Guid.Empty) _SATSSATResult.ResultID = Guid.NewGuid(); _SATSSATResult.StudentID = studentInfo.StudentID; repository.SaveExamResult(_SATSSATResult); } ExamResultEntity _SAT2Result = ajaxData.SAT2Result; if (_SAT2Result != null) { if (_SAT2Result.ResultID == Guid.Empty) _SAT2Result.ResultID = Guid.NewGuid(); _SAT2Result.StudentID = studentInfo.StudentID; repository.SaveExamResult(_SAT2Result); } return Json(new { TPInfo=true, StudentId = studentInfo.StudentID }); }
/// <summary> /// 渲染初访登记表——学生的培训、课程、考试信息 /// </summary> /// <param name="id">学生ID</param> /// <returns></returns> public ViewResult FirstRegFormTP(string id) { Guid studentID = new Guid(id); StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == studentID); StudentTPInfoEntity studentTPInfo = null; if (repository.StudentTPInfo.SingleOrDefault(s => s.StudentID == studentID) != null) { studentTPInfo = repository.StudentTPInfo.SingleOrDefault(s => s.StudentID == studentID); } else studentTPInfo = new StudentTPInfoEntity { StudentID = studentID }; ExamResultEntity tfIELTSResult = null; if(repository.ExamResult.FirstOrDefault(e=>e.StudentID == studentID && (e.ExamType == ExamType.TOFEL || e.ExamType == ExamType.IELTS)) != null) tfIELTSResult = repository.ExamResult.FirstOrDefault(e=>e.StudentID == studentID && (e.ExamType == ExamType.TOFEL || e.ExamType == ExamType.IELTS)); else tfIELTSResult = new ExamResultEntity{ExamType = Domain.Enum.ExamType.TOFEL,StudentID = studentID,ExamID = Guid.NewGuid()}; ExamResultEntity sATSSATResult = null; ExamResultSATSSATEntity sATSSATResultDetail = null; if (repository.ExamResult.FirstOrDefault(e => e.StudentID == studentID && (e.ExamType == ExamType.SAT || e.ExamType == ExamType.SSAT)) != null) { sATSSATResult = repository.ExamResult.FirstOrDefault(e => e.StudentID == studentID && (e.ExamType == ExamType.SAT || e.ExamType == ExamType.SSAT)); if (repository.ExamResultSATSSAT.SingleOrDefault(e => e.ExamID == sATSSATResult.ExamID) != null) { sATSSATResultDetail = repository.ExamResultSATSSAT.SingleOrDefault(e => e.ExamID == sATSSATResult.ExamID); } else { sATSSATResultDetail = new ExamResultSATSSATEntity { ExamID = Guid.NewGuid() }; } } else { Guid detailId = Guid.NewGuid(); sATSSATResult = new ExamResultEntity { ExamType = Domain.Enum.ExamType.SAT,StudentID = studentID,ResultID=Guid.NewGuid(),ExamID=detailId}; sATSSATResultDetail = new ExamResultSATSSATEntity { ExamID = detailId }; } ExamResultEntity sAT2Result = null; if (repository.ExamResult.FirstOrDefault(e => e.StudentID == studentID && e.ExamType == ExamType.SAT2) != null) { sAT2Result = repository.ExamResult.FirstOrDefault(e => e.StudentID == studentID && e.ExamType == ExamType.SAT2); } else sAT2Result = new ExamResultEntity { ExamType = Domain.Enum.ExamType.SAT2, StudentID = studentID }; FirstInterviewTPModel tpModel = new FirstInterviewTPModel { StudentInfo=studentInfo, StudentTPInfo = studentTPInfo, TFIELTSResult = tfIELTSResult, TFIELTSResultDetail = new ExamResultTFIELTSEntity(), SATSSATResult = sATSSATResult, SATSSATResultDetail = sATSSATResultDetail, SAT2Result = sAT2Result }; return View(tpModel); }