示例#1
0
 private EditExamPaperInfo UpdatePaper(EditExamPaperInfo paperInfo)
 {
     DbModel.ExamPaperInfo updateInfo = InternalLoad(paperInfo.Id);
     updateInfo.ExamName     = paperInfo.Name;
     updateInfo.ExamMinute   = paperInfo.ExamMinute;
     updateInfo.ExamScore    = paperInfo.ExamScore;
     updateInfo.QuestionNums = paperInfo.QuestionRank;
     updateInfo.ExamDateFrom = paperInfo.ExamDateFrom;
     updateInfo.ExamDateTo   = paperInfo.ExamDateTo;
     updateInfo.Remark       = paperInfo.Remark;
     _repository.Save(updateInfo);
     if (paperInfo.QuestionIds != null && paperInfo.QuestionIds.Count > 0)
     {
         IEnumerable <QuestionInfo> oldQuestions    = QueryQuestion(paperInfo.Id);
         List <QuestionInfo>        deleteQuestions = new List <QuestionInfo>();
         foreach (QuestionInfo question in oldQuestions)
         {
             if (!paperInfo.QuestionIds.Contains(question.Id))
             {
                 deleteQuestions.Add(question);
             }
         }
         SaveRelation(paperInfo);
         RemoveRelation(paperInfo, deleteQuestions);
     }
     return(paperInfo);
 }
示例#2
0
        public ExamPaperInfo Load(int paperId)
        {
            DbModel.ExamPaperInfo paperInfo = InternalLoad(paperId);
            if (paperInfo == null)
            {
                return(null);
            }
            ExamPaperInfo result = new ExamPaperInfo();

            result.Id           = paperInfo.Id;
            result.Name         = paperInfo.ExamName;
            result.ExamMinute   = paperInfo.ExamMinute;
            result.ExamScore    = paperInfo.ExamScore;
            result.QuestionRank = paperInfo.QuestionNums;
            result.ExamDateFrom = paperInfo.ExamDateFrom;
            result.ExamDateTo   = paperInfo.ExamDateTo;
            result.Remark       = paperInfo.Remark;
            result.Questions    = QueryQuestion(result.Id).ToList();
            result.QuestionIds  = new List <int>();
            foreach (QuestionInfo question in result.Questions)
            {
                result.QuestionIds.Add(question.Id);
            }
            return(result);
        }
示例#3
0
 private EditExamPaperInfo CreatePaper(EditExamPaperInfo paperInfo)
 {
     DbModel.ExamPaperInfo createInfo = new DbModel.ExamPaperInfo();
     createInfo.ExamName     = paperInfo.Name;
     createInfo.ExamMinute   = paperInfo.ExamMinute;
     createInfo.ExamScore    = paperInfo.ExamScore;
     createInfo.QuestionNums = paperInfo.QuestionRank;
     createInfo.ExamDateFrom = paperInfo.ExamDateFrom;
     createInfo.ExamDateTo   = paperInfo.ExamDateTo;
     createInfo.Remark       = paperInfo.Remark;
     createInfo.CreateUserId = _loginUser.Id;
     createInfo.CreateDate   = DateTime.Now;
     createInfo   = _repository.Save(createInfo);
     paperInfo.Id = createInfo.Id;
     if (paperInfo.QuestionIds != null && paperInfo.QuestionIds.Count > 0)
     {
         SaveRelation(paperInfo);
     }
     return(paperInfo);
 }