/// <summary> /// 根据主键ID获取简答题 /// </summary> public ServiceInvokeDTO<WordItemDTO> GetWordByID(int id) { log.Debug(Constant.DEBUG_START); ServiceInvokeDTO<WordItemDTO> result = null; try { WordItemDTO wordDTO = null; // --> DTO WordItem word = wordDAL.GetByID(id); if (word != null) { wordDTO = new WordItemDTO(word); wordDTO.ChapterName = chapterDAL.GetByID(word.ChapterID).Name; } result = new ServiceInvokeDTO<WordItemDTO>(InvokeCode.SYS_INVOKE_SUCCESS, wordDTO); } catch (Exception ex) { log.Error(ex); throw ex; } log.Debug(Constant.DEBUG_END); return result; }
/// <summary> /// 以分页的形式查询简答题 /// </summary> public ServiceInvokeDTO<QueryResultDTO<WordItemDTO>> QueryWord(QueryArgsDTO<WordItem> queryDTO, int courseID) { log.Debug(Constant.DEBUG_START); ServiceInvokeDTO<QueryResultDTO<WordItemDTO>> result = null; try { QueryResultDTO<WordItemDTO> resultData = null; // -->DTO QueryResultDTO<WordItem> queryData = wordDAL.Query(queryDTO, courseID); if (queryData != null) { resultData = new QueryResultDTO<WordItemDTO>(); resultData.PageIndex = queryData.PageIndex; resultData.PageSize = queryData.PageSize; resultData.TotalRecordCount = queryData.TotalRecordCount; List<WordItemDTO> dtos = new List<WordItemDTO>(); if (queryData.List != null) { foreach (var word in queryData.List) { WordItemDTO wordDTO = new WordItemDTO(word); wordDTO.ChapterName = chapterDAL.GetByID(word.ChapterID).Name; dtos.Add(wordDTO); } } resultData.List = dtos; } result = new ServiceInvokeDTO<QueryResultDTO<WordItemDTO>>(InvokeCode.SYS_INVOKE_SUCCESS, resultData); } catch (Exception ex) { log.Error(ex); result = new ServiceInvokeDTO<QueryResultDTO<WordItemDTO>>(InvokeCode.SYS_INNER_ERROR); } log.Debug(Constant.DEBUG_END); return result; }