/// <summary>
        /// 根据唯一标识获得答题卡结果
        /// </summary>
        /// <param name="id">唯一标识</param>
        /// <returns>答题卡结果</returns>
        /// <exception cref="ArgumentException">参数错误</exception>
        public AnswerSheetResultModel GetAnswerSheetResultInfoByID(Guid id)
        {
            V_AnswerSheet dbAnSM = _dal.GetDBModelViewInfoByID(id);

            if (dbAnSM != null)
            {
                List <T_AnswerSheetDetails> dbAnSDMs = _answerSheetDetailsDAL.GetAnswerSheetDetailsInfoByAnswerSheetID(id);
                if (dbAnSDMs.Count > 0)
                {
                    AnswerSheetResultModel resM             = new AnswerSheetResultModel(dbAnSM);
                    V_Paper                       paperM    = _paperDAL.GetDBModelViewInfoByID(dbAnSDMs[0].T_Answer.T_Problem.T_Paper.ID);
                    List <V_Problem>              problemMs = _problemDAL.GetProblemViewInfoByPaperID(paperM.ID);
                    List <V_Answer>               answerMs;
                    AnswerSheetResultAnswerModel  asraM;
                    AnswerSheetResultProblemModel asrpM;
                    AnswerSheetResultPaperModel   asrapaM = new AnswerSheetResultPaperModel(paperM);
                    #region 组装问题
                    asrapaM.Problems = new List <AnswerSheetResultProblemModel>();
                    foreach (V_Problem item in problemMs)
                    {
                        asrpM = new AnswerSheetResultProblemModel(item);
                        #region 组装答案
                        answerMs      = _answerDAL.GetAnswerViewInfoByProblemID(item.ID);
                        asrpM.Answers = new List <AnswerSheetResultAnswerModel>();
                        foreach (V_Answer answerM in answerMs)
                        {
                            asraM          = new AnswerSheetResultAnswerModel(answerM);
                            asraM.IsSelect = (from m in dbAnSDMs
                                              where m.FK_Answer == answerM.ID
                                              select m).FirstOrDefault() != null;
                            asrpM.Answers.Add(asraM);
                        }
                        #endregion
                        asrapaM.Problems.Add(asrpM);
                    }
                    #endregion
                    resM.Paper = asrapaM;
                    return(resM);
                }
                else
                {
                    throw new ArgumentException($"参数{nameof(id)}错误");
                }
            }
            else
            {
                throw new ArgumentException($"参数{nameof(id)}错误");
            }
        }
Beispiel #2
0
        public MResultModel GetAnswerSheetResultInfoByID(Guid ID)
        {
            MResultModel resM;

            try
            {
                AnswerSheetResultModel asrM = _answerSheetBLL.GetAnswerSheetResultInfoByID(ID);
                resM = MResultModel <AnswerSheetResultModel> .GetSuccessResultM(asrM, "查询成功");
            }
            catch (ArgumentException ex)
            {
                resM = MResultModel.GetFailResultM(ex.Message);
            }
            return(resM);
        }
 public void GetAnswerSheetResultInfoByIDTest()
 {
     AnswerSheetResultModel resM = _answerSheetBLL.GetAnswerSheetResultInfoByID(Guid.Parse("4A4602E2-C068-4C99-B483-06D849F4472A"));
     string json = ConvertManager.ModelToJson(resM);
 }