Exemplo n.º 1
0
        /// <summary>
        /// 根据主键ID获取判断题
        /// </summary>
        public ServiceInvokeDTO<JudgeItemDTO> GetJudgeByID(int id)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO<JudgeItemDTO> result = null;
            try
            {
                JudgeItemDTO judgeDTO = null;

                // --> DTO
                JudgeItem judge = judgeDAL.GetByID(id);
                if (judge != null)
                {
                    judgeDTO = new JudgeItemDTO(judge);
                    judgeDTO.ChapterName = chapterDAL.GetByID(judge.ChapterID).Name;
                }
                result = new ServiceInvokeDTO<JudgeItemDTO>(InvokeCode.SYS_INVOKE_SUCCESS, judgeDTO);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 以分页的形式查询判断题
        /// </summary>
        public ServiceInvokeDTO<QueryResultDTO<JudgeItemDTO>> QueryJudge(QueryArgsDTO<JudgeItem> queryDTO, int courseID)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO<QueryResultDTO<JudgeItemDTO>> result = null;
            try
            {
                QueryResultDTO<JudgeItemDTO> resultData = null;

                // -->DTO
                QueryResultDTO<JudgeItem> queryData = judgeDAL.Query(queryDTO, courseID);
                if (queryData != null)
                {
                    resultData = new QueryResultDTO<JudgeItemDTO>();
                    resultData.PageIndex = queryData.PageIndex;
                    resultData.PageSize = queryData.PageSize;
                    resultData.TotalRecordCount = queryData.TotalRecordCount;

                    List<JudgeItemDTO> dtos = new List<JudgeItemDTO>();
                    if (queryData.List != null)
                    {
                        foreach (var judge in queryData.List)
                        {
                            JudgeItemDTO judgeDTO = new JudgeItemDTO(judge);
                            judgeDTO.ChapterName = chapterDAL.GetByID(judge.ChapterID).Name;
                            dtos.Add(judgeDTO);
                        }
                    }

                    resultData.List = dtos;
                }

                result = new ServiceInvokeDTO<QueryResultDTO<JudgeItemDTO>>(InvokeCode.SYS_INVOKE_SUCCESS, resultData);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                result = new ServiceInvokeDTO<QueryResultDTO<JudgeItemDTO>>(InvokeCode.SYS_INNER_ERROR);
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }