示例#1
0
        /// <summary>
        /// 以分页的形式查询不定项选择题
        /// </summary>
        public ServiceInvokeDTO<QueryResultDTO<UncertainItemDTO>> QueryUncertain(QueryArgsDTO<UncertainItem> queryDTO, int courseID)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO<QueryResultDTO<UncertainItemDTO>> result = null;
            try
            {
                QueryResultDTO<UncertainItemDTO> resultData = null;

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

                    List<UncertainItemDTO> dtos = new List<UncertainItemDTO>();
                    if (queryData.List != null)
                    {
                        foreach (var uncertain in queryData.List)
                        {
                            UncertainItemDTO uncertainDTO = new UncertainItemDTO(uncertain);
                            uncertainDTO.ChapterName = chapterDAL.GetByID(uncertain.ChapterID).Name;
                            uncertainDTO.SubChoices = uncertainSubChoiceDAL.GetByUncertainItemID(uncertain.ID);
                            dtos.Add(uncertainDTO);
                        }
                    }

                    resultData.List = dtos;
                }

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

            return result;
        }
示例#2
0
        /// <summary>
        /// 根据主键ID获取不定项选择题
        /// </summary>
        public ServiceInvokeDTO<UncertainItemDTO> GetUncertainByID(int id)
        {
            log.Debug(Constant.DEBUG_START);
            ServiceInvokeDTO<UncertainItemDTO> result = null;
            try
            {
                UncertainItemDTO uncertainDTO = null;

                // --> DTO
                UncertainItem uncertain = uncertainDAL.GetByID(id);
                if (uncertain != null)
                {
                    uncertainDTO = new UncertainItemDTO(uncertain);
                    uncertainDTO.ChapterName = chapterDAL.GetByID(uncertain.ChapterID).Name;
                    uncertainDTO.SubChoices = uncertainSubChoiceDAL.GetByUncertainItemID(uncertain.ID);
                }
                result = new ServiceInvokeDTO<UncertainItemDTO>(InvokeCode.SYS_INVOKE_SUCCESS, uncertainDTO);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw ex;
            }
            log.Debug(Constant.DEBUG_END);

            return result;
        }