ExamResultGREGMATModel GetGREGMATExamResult(Guid studentID) { //从数据库中根据StudentID、ExamDate、ExamType 选择考试条目 ExamResultEntity examResult = repository.ExamResult .FirstOrDefault(e => e.StudentID == studentID && e.IsBeforeSign == true && (e.ExamType == ExamType.GMAT || e.ExamType == ExamType.GRE)); if (examResult == null) { examResult = new ExamResultEntity { ResultID = Guid.NewGuid(), StudentID = studentID, ExamID = Guid.NewGuid(), IsBeforeSign = true, ExamType = ExamType.GRE }; } ExamResultGREGMATEntity examResultDetail = repository.ExamResultGREGMAT.SingleOrDefault(e => e.ExamID == examResult.ExamID); if (examResultDetail == null) { examResultDetail = new ExamResultGREGMATEntity { ExamID = examResult.ExamID, Total = examResult.Total }; } return(new ExamResultGREGMATModel { ExamResult = examResult, ExamResultDetail = examResultDetail }); }
public void SaveExamResult(ExamResultEntity examResult) { ExamResultEntity originResult = context.ExamResult.SingleOrDefault(e => e.ResultID == examResult.ResultID); if (originResult == null) { if (examResult.Total > 0) { context.ExamResult.Add(examResult); } else { return; } } else { if (examResult.Total > 0) { context.Entry(originResult).CurrentValues.SetValues(examResult); } else { context.ExamResult.Remove(originResult); } } context.SaveChanges(); }
public JsonResult PostFirstInterviewRegTPForm(FirstInterviewRegModel ajaxData) { if (ajaxData == null || ajaxData.StudentInfo == null) { return(Json(false)); } StudentTPInfoEntity studentTPInfo = ajaxData.StudentTPInfo; StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == ajaxData.StudentInfo.StudentID); AppRelationsEntity appRelation = repository.AppRelation.SingleOrDefault(a => a.StudentID == studentInfo.StudentID); studentInfo.EducationIntention = ajaxData.StudentInfo.EducationIntention; studentInfoRepository.SaveStudentTPInfo(studentTPInfo); studentInfoRepository.SaveStudentInfo(studentInfo, appRelation); ExamResultEntity _TFIELTSResult = ajaxData.TFIELTSResult; ExamResultTFIELTSEntity _TFIELTSResultDetail = ajaxData.TFIELTSResultDetail; if ((_TFIELTSResult.ExamType == ExamType.TOFEL || _TFIELTSResult.ExamType == ExamType.IELTS)) { repository.SaveExamResult(_TFIELTSResult); if (_TFIELTSResultDetail.ExamID != _TFIELTSResult.ExamID) { _TFIELTSResultDetail.ExamID = _TFIELTSResult.ExamID = Guid.NewGuid(); } repository.SaveExamResultTFIELTS(_TFIELTSResultDetail); } EducationIntention eduIntention = studentInfo.EducationIntention; switch (eduIntention) { case EducationIntention.高中: { ajaxData.SATSSATResult.ExamType = ExamType.SSAT; SaveSSATResult(ajaxData.SATSSATResult, ajaxData.SATSSATResultDetail); break; } case EducationIntention.本科: { ajaxData.SATSSATResult.ExamType = ExamType.SAT; repository.SaveExamResult(ajaxData.SAT2Result); SaveSATResult(ajaxData.SATSSATResult, ajaxData.SATSSATResultDetail); break; } case EducationIntention.研究生: SaveGreGmatResult(ajaxData.GREGMATResult, ajaxData.GREGMATResultDetail); break; default: break; } return(Json(true)); }
void SaveSATResult(ExamResultEntity satResult, ExamResultSATSSATEntity satResultDetail) { repository.SaveExamResult(satResult); if (satResultDetail.ExamID != satResult.ExamID) { satResultDetail.ExamID = satResult.ExamID = Guid.NewGuid(); } repository.SaveExamResultSATSSAT(satResultDetail); }
void SaveGreGmatResult(ExamResultEntity greGmatResult, ExamResultGREGMATEntity greGmatResultDetail) { if (greGmatResult.ExamType == ExamType.GRE || greGmatResult.ExamType == ExamType.GMAT) { repository.SaveExamResult(greGmatResult); if (greGmatResultDetail.ExamID != greGmatResult.ExamID) { greGmatResultDetail.ExamID = greGmatResult.ExamID = Guid.NewGuid(); } repository.SaveExamResultGREGMAT(greGmatResultDetail); return; } else { return; } }
public void SaveExamResult(ExamResultEntity examResult) { if (examResult.ResultID == Guid.Empty) { examResult.ResultID = Guid.NewGuid(); } ExamResultEntity originResult = context.ExamResult.SingleOrDefault(e => e.ResultID == examResult.ResultID); if (originResult == null) { context.ExamResult.Add(examResult); } else { context.Entry(originResult).CurrentValues.SetValues(examResult); } context.SaveChanges(); }
ExamResultEntity GetAPResult(Guid studentID) { //从数据库中根据StudentID、ExamDate、ExamType 选择考试条目 ExamResultEntity examResult = repository.ExamResult .FirstOrDefault(e => e.StudentID == studentID && e.IsBeforeSign == true && e.ExamType == ExamType.AP); if (examResult == null) { examResult = new ExamResultEntity { ResultID = Guid.NewGuid(), StudentID = studentID, ExamID = Guid.NewGuid(), IsBeforeSign = true, ExamType = ExamType.AP }; } return(examResult); }
/// <summary> /// 根据学生ID获取初访数据 /// </summary> /// <param name="studentID">学生ID</param> /// <returns></returns> public JsonResult GetFirstInterviewRegData(string studentID) { if (studentID == null || studentID == string.Empty) { return(Json(false, JsonRequestBehavior.AllowGet)); } Guid id = new Guid(studentID); StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == id); AppRelationsEntity appRelation = repository.AppRelation.SingleOrDefault(a => a.StudentID == id); StudentTPInfoEntity studentTP = GetStudentTP(id); ExamResultTFIELTSModel tfIELTSModel = GetTFIELTSExamResult(id); ExamResultSATSSATModel satSSATModel = GetSATSSATExamResult(id); ExamResultEntity sat2Model = GetSAT2ExamResult(id); ExamResultGREGMATModel greGmatModel = GetGREGMATExamResult(id); ExamResultEntity apModel = GetAPResult(id); IEnumerable <StudentSourceItemEntity> studentSourceList = GetStudentSourceList(); IEnumerable <StudentFromEntity> studentFromList = GetStudentFromList(id); IEnumerable <StudentFlashPointEntity> studentFlashPointList = GetFlashPointList(id); FirstInterviewRegModel firstInterviewRegMode = new FirstInterviewRegModel { StudentInfo = studentInfo, AppRelation = appRelation, StudentTPInfo = studentTP, TFIELTSResult = tfIELTSModel.ExamResult, TFIELTSResultDetail = tfIELTSModel.ExamResultDetail, SATSSATResult = satSSATModel.ExamResult, SATSSATResultDetail = satSSATModel.ExamResultDetail, SAT2Result = sat2Model, GREGMATResult = greGmatModel.ExamResult, GREGMATResultDetail = greGmatModel.ExamResultDetail, APResult = apModel, StudentSourceList = studentSourceList, StudentFromList = studentFromList, StudentFlashPointList = studentFlashPointList }; return(Json(firstInterviewRegMode, JsonRequestBehavior.AllowGet)); }
/// <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)); }
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 })); }