Example #1
0
 public ExamRecordInfo AddRecord(ExamRecordInfo recordInfo)
 {
     try
     {
         DbModel.ExamRecordInfo saveInfo = new DbModel.ExamRecordInfo();
         saveInfo.ExamPaperId  = recordInfo.ExamPaperId;
         saveInfo.ExamScore    = recordInfo.ExamScore;
         saveInfo.IsPassed     = recordInfo.IsPassed;
         saveInfo.LeftTime     = recordInfo.LeftTime;
         saveInfo.CreateUserId = recordInfo.CreateUser == null ? _loginUser.Id : recordInfo.CreateUser.Id;
         saveInfo.CreateDate   = DateTime.Now;
         saveInfo.BeginTime    = recordInfo.BeginTime;
         saveInfo                = _recordRepository.Create(saveInfo);
         recordInfo.Id           = saveInfo.Id;
         recordInfo.CreateDate   = saveInfo.CreateDate;
         recordInfo.CreateUserId = saveInfo.CreateUserId;
         recordInfo.ExamPaper    = _examPaperApp.Load(saveInfo.ExamPaperId);
         foreach (ExamQuestionRecordInfo questionRecord in recordInfo.QuestionRecords)
         {
             AddQuestionRecord(recordInfo.Id, questionRecord);
         }
     }
     catch (Exception ex)
     {
         _log.LogError(ex, nameof(AddRecord));
         throw;
     }
     return(recordInfo);
 }
Example #2
0
        public async Task <ExamRecordInfo> Load(Expression <Func <DbModel.ExamRecordInfo, bool> > expression)
        {
            DbModel.ExamRecordInfo recordInfo = _recordRepository.Load(expression);
            ExamRecordInfo         result     = new ExamRecordInfo();

            result.Id              = recordInfo.Id;
            result.ExamPaperId     = recordInfo.ExamPaperId;
            result.ExamScore       = recordInfo.ExamScore;
            result.IsPassed        = recordInfo.IsPassed;
            result.LeftTime        = recordInfo.LeftTime;
            result.BeginTime       = recordInfo.BeginTime;
            result.CreateUserId    = recordInfo.CreateUserId;
            result.CreateDate      = recordInfo.CreateDate;
            result.CreateUser      = _userApp.Load(result.CreateUserId.ToString());
            result.ExamPaper       = _examPaperApp.Load(result.ExamPaperId);
            result.QuestionRecords = QueryRecordQuestion(result.Id).ToList();
            foreach (ExamQuestionRecordInfo questionRecord in result.QuestionRecords)
            {
                questionRecord.ExamRecord = result;
            }
            return(result);
        }