Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public void SaveStudentTPInfo(StudentTPInfoEntity studentTPInfo)
 {
     if (studentTPInfo.StudentID == Guid.Empty || context.StudentsInfo.SingleOrDefault(s=>s.StudentID == studentTPInfo.StudentID) == null)
     {
         throw new Exception("不存在相关联的学生,StudentID为空或无该ID");
     }
     StudentTPInfoEntity originTPInfo = context.StudentTPInfo.SingleOrDefault(s => s.StudentID == studentTPInfo.StudentID);
     if (originTPInfo == null)
     {
         context.StudentTPInfo.Add(studentTPInfo);
     }
     else
     {
         context.Entry(originTPInfo).CurrentValues.SetValues(studentTPInfo);
     }
     context.SaveChanges();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 根据学生ID返回课程信息TPInfo
 /// </summary>
 /// <param name="studentID"></param>
 /// <returns></returns>
 StudentTPInfoEntity GetStudentTP(Guid studentID)
 {
     StudentTPInfoEntity tpInfo = repository.StudentTPInfo.SingleOrDefault(s => s.StudentID == studentID);
     if (tpInfo == null)
     {
         tpInfo = new StudentTPInfoEntity { StudentID = studentID };
         return tpInfo;
     }
     else
     {
         return tpInfo;
     }
 }