コード例 #1
0
        /// <summary>
        /// 题目分类添加页面
        /// </summary>
        /// <returns>操作后的结果</returns>
        public ActionResult CategoryAdd()
        {
            ProblemCategoryEntity entity = new ProblemCategoryEntity()
            {
                Order = 255
            };

            return View("CategoryEdit", entity);
        }
コード例 #2
0
        /// <summary>
        /// 更新一条题目类型种类
        /// </summary>
        /// <param name="entity">题目类型种类实体</param>
        /// <returns>是否成功更新</returns>
        public static IMethodResult AdminUpdateProblemCategory(ProblemCategoryEntity entity)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            if (entity.TypeID <= 0)
            {
                return MethodResult.InvalidRequest(RequestType.ProblemCategory);
            }

            if (String.IsNullOrEmpty(entity.Title))
            {
                return MethodResult.FailedAndLog("Problem category title cannot be NULL!");
            }

            Boolean success = ProblemCategoryRepository.Instance.UpdateEntity(entity) > 0;

            if (!success)
            {
                return MethodResult.FailedAndLog("No problem category was updated!");
            }

            ProblemCategoryCache.RemoveProblemCategoryListCache();//删除缓存

            return MethodResult.SuccessAndLog("Admin update problem category, id = {0}", entity.TypeID.ToString());
        }
コード例 #3
0
        /// <summary>
        /// 增加一条题目类型种类
        /// </summary>
        /// <param name="entity">题目类型种类实体</param>
        /// <returns>是否成功增加</returns>
        public static IMethodResult AdminInsertProblemCategory(ProblemCategoryEntity entity)
        {
            if (!AdminManager.HasPermission(PermissionType.ProblemManage))
            {
                throw new NoPermissionException();
            }

            if (String.IsNullOrEmpty(entity.Title))
            {
                return MethodResult.FailedAndLog("Problem category title cannot be NULL!");
            }

            Boolean success = ProblemCategoryRepository.Instance.InsertEntity(entity) > 0;

            if (!success)
            {
                return MethodResult.FailedAndLog("No problem category was added!");
            }

            ProblemCategoryCache.RemoveProblemCategoryListCache();//删除缓存

            return MethodResult.SuccessAndLog("Admin add problem category, title = {0}", entity.Title);
        }
コード例 #4
0
        public ActionResult CategoryAdd(FormCollection form)
        {
            ProblemCategoryEntity entity = new ProblemCategoryEntity()
            {
                Title = form["title"],
                Order = form["order"].ToInt32(0)
            };

            return ResultToMessagePage(ProblemCategoryManager.AdminInsertProblemCategory, entity, "Your have added problem category successfully!");
        }
コード例 #5
0
        public ActionResult CategoryEdit(Int32 id, FormCollection form)
        {
            ProblemCategoryEntity entity = new ProblemCategoryEntity()
            {
                TypeID = id,
                Title = form["title"],
                Order = form["order"].ToInt32(0)
            };

            return ResultToMessagePage(ProblemCategoryManager.AdminUpdateProblemCategory, entity, "Your have edited problem category successfully!");
        }