/// <summary> /// 给试卷题型添加题目 /// </summary> /// <returns></returns> public bool AddPaperDetailQuestions(ExamPaperPostModel model) { W_ExamPaper paper = Orm.Single <W_ExamPaper>(x => x.ID == model.examPaperId); if (paper == null) { throw new ApiException("试卷不存在或者已删除"); } W_ExamPaperDetail paperDetail = Orm.Single <W_ExamPaperDetail>(x => x.ID == model.examPaperDetailId); if (paperDetail == null) { throw new ApiException("试卷题型不存在或者已删除"); } if (paperDetail.ExamPaper_ID != paper.ID) { throw new ApiException("试卷题型与试卷不匹配"); } List <W_ExamPaperDetail_Detail> list = Orm.Select <W_ExamPaperDetail_Detail>(x => x.ExamPaper_ID == model.examPaperId && x.ExamPaper_Detail_ID == model.examPaperDetailId).ToList(); if (list.Count + model.questionIds.Length > paperDetail.Num) { throw new ApiException("选择的题目不能超过配置的数目"); } SqlMapper.BeginTransaction(); try { foreach (int questionId in model.questionIds) { Orm.Insert <W_ExamPaperDetail_Detail>(new W_ExamPaperDetail_Detail() { ExamPaper_ID = model.examPaperId, ExamPaper_Detail_ID = model.examPaperDetailId, Question_ID = questionId }); } SqlMapper.CommitTransaction(); } catch { SqlMapper.RollBackTransaction(); return(false); } return(true); }
/// <summary> /// 删除试卷题目 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool DeleteExamPaperDetailDetail(ExamPaperPostModel request) { return(Orm.DeleteByIds <W_ExamPaperDetail_Detail>(request.Ids) > 0); }
public dynamic DeleteExamPaperDetailDetail(ExamPaperPostModel request) { return(Success(mapper.DeleteExamPaperDetailDetail(request) ? "操作成功" : "操作失败")); }
public dynamic AddPaperDetailQuestions(ExamPaperPostModel model) { return(Success(mapper.AddPaperDetailQuestions(model) ? "操作成功" : "操作失败")); }