Ejemplo n.º 1
0
        /// <summary>
        /// 获取题目类型种类列表
        /// </summary>
        /// <param name="pageIndex">页面索引</param>
        /// <returns>题目类型种类列表</returns>
        public static PagedList <ProblemCategoryEntity> AdminGetProblemCategoryList(Int32 pageIndex)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            Int32 pageSize    = AdminManager.ADMIN_LIST_PAGE_SIZE;
            Int32 recordCount = ProblemCategoryManager.AdminCountProblemCategoryList();

            return(ProblemCategoryRepository.Instance
                   .GetEntities(pageIndex, pageSize, recordCount)
                   .ToPagedList(pageSize, recordCount));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取题目类型列表
        /// </summary>
        /// <param name="problemID">题目ID</param>
        /// <returns>题目选择的类型列表</returns>
        public static IMethodResult AdminGetProblemCategoryItemList(Int32 problemID)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            List <ProblemCategoryItemEntity> lstPT = ProblemCategoryItemRepository.Instance.GetEntities(problemID);
            StringBuilder sb = new StringBuilder();

            List <ProblemCategoryEntity> lstSelectedList   = new List <ProblemCategoryEntity>();
            List <ProblemCategoryEntity> lstUnSelectedList = new List <ProblemCategoryEntity>(ProblemCategoryManager.GetProblemCategoryList());

            if (lstPT == null)
            {
                lstPT = new List <ProblemCategoryItemEntity>();
            }

            for (Int32 i = 0; i < lstPT.Count; i++)
            {
                sb.Append(lstPT[i].TypeID.ToString()).Append(",");

                for (Int32 j = 0; j < lstUnSelectedList.Count; j++)
                {
                    if (lstUnSelectedList[j].TypeID == lstPT[i].TypeID)
                    {
                        lstSelectedList.Add(lstUnSelectedList[j]);
                        lstUnSelectedList.RemoveAt(j);
                        break;
                    }
                }
            }

            return(MethodResult.Success(new Tuple <String, List <ProblemCategoryEntity>, List <ProblemCategoryEntity> >(sb.ToString(), lstUnSelectedList, lstSelectedList)));
        }