Пример #1
0
 ExamResultTFIELTSModel GetTFIELTSExamResult(Guid studentID)
 {
     //从数据库中根据StudentID、ExamDate、ExamType 选择考试条目
     ExamResultEntity examResult = repository.ExamResult
         .FirstOrDefault(e => e.StudentID == studentID && e.IsBeforeSign == true && (e.ExamType == ExamType.TOFEL || e.ExamType == ExamType.IELTS));
     if (examResult == null)
     {
         examResult = new ExamResultEntity
         {
             ResultID = Guid.NewGuid(),
             StudentID = studentID,
             ExamID = Guid.NewGuid(),
             IsBeforeSign = true,
             ExamType = ExamType.TOFEL
         };
     }
     ExamResultTFIELTSEntity examResultDetail = repository.ExamResultTFIELTS.SingleOrDefault(e => e.ExamID == examResult.ExamID);
     if (examResultDetail == null)
     {
         examResultDetail = new ExamResultTFIELTSEntity {
             ExamID = examResult.ExamID,
             Total = examResult.Total
         };
     }
     return new ExamResultTFIELTSModel
     {
         ExamResult = examResult,
         ExamResultDetail = examResultDetail
     };
 }
Пример #2
0
 public void SaveExamResultTFIELTS(ExamResultTFIELTSEntity tfIELTSDetail)
 {
     if (tfIELTSDetail.ExamID == Guid.Empty)
         tfIELTSDetail.ExamID = Guid.NewGuid();
     ExamResultTFIELTSEntity originDetail = context.ExamResult_TF_IELTS.SingleOrDefault(e => e.ExamID == tfIELTSDetail.ExamID);
     if (originDetail == null)
     {
         context.ExamResult_TF_IELTS.Add(tfIELTSDetail);
     }
     else
     {
         context.Entry(originDetail).CurrentValues.SetValues(tfIELTSDetail);
     }
     context.SaveChanges();
 }
Пример #3
0
 public void SaveExamResultTFIELTS(ExamResultTFIELTSEntity tfIELTSDetail)
 {
     ExamResultTFIELTSEntity originDetail = context.ExamResult_TF_IELTS.SingleOrDefault(e => e.ExamID == tfIELTSDetail.ExamID);
     if (originDetail == null)
     {
         if (tfIELTSDetail.Total > 0)
             context.ExamResult_TF_IELTS.Add(tfIELTSDetail);
         else
             return;
     }
     else
     {
         if (tfIELTSDetail.Total > 0)
             context.Entry(originDetail).CurrentValues.SetValues(tfIELTSDetail);
         else
             context.ExamResult_TF_IELTS.Remove(originDetail);
     }
     context.SaveChanges();
 }