コード例 #1
0
        public ActionResult SelectionSetting(string level_1_id /*selection_id*/, string board_list)
        {
            if (!Util.IsAjaxRequest(Request))
            {
                Util.ThrowBadRequestException("Not ajax post.");
            }
            if (!ReCaptcha.Validate())
            {
                Util.ThrowBadRequestException("驗證碼不正確。");
            }

            int cnt = SandId.CountBoardList(board_list);

            if (cnt == -1)
            {
                Util.ThrowBadRequestException("留言板ID格式不正確。");
            }
            else if (cnt == 0)
            {
                Util.ThrowBadRequestException("未包含任何留言板ID。");
            }
            else if (cnt > HeartsConfiguration.MAX_NUM_OF_BOARDS_IN_A_SELECTION)
            {
                Util.ThrowBadRequestException("留言板數量超過" + HeartsConfiguration.MAX_NUM_OF_BOARDS_IN_A_SELECTION + "個。");
            }

            SelectionInfoStore.SetSelectionSetting(level_1_id, board_list);

            return(Json(new { ok = true }));
        }
コード例 #2
0
        public ActionResult CreateSelection(string selection_name)
        {
            if (!Util.IsAjaxRequest(Request))
            {
                Util.ThrowBadRequestException("Not ajax post.");
            }

            if (!ReCaptcha.Validate())
            {
                Util.ThrowBadRequestException("驗證碼不正確。");
            }

            if (selection_name.Length < HeartsConfiguration.BOARD_NAME_FIELD_MIN_LEN)
            {
                Util.ThrowBadRequestException("區域名長度過短。");
            }
            else if (selection_name.Length > HeartsConfiguration.BOARD_NAME_FIELD_MAX_LEN)
            {
                Util.ThrowBadRequestException("區域名長度過長。");
            }
            else if (!Util.WithinCharSetUserName(selection_name))
            {
                Util.ThrowBadRequestException("區域名含有不合法的字元。");
            }
            else if (selection_name == "RETURN_FAIL")
            {
                Util.ThrowBadRequestException("區域名為RETURN_FAIL。");
            }

            string selection_id = SelectionInfoStore.CreateSelection(selection_name + '區');

            return(Json(new { selection_id = selection_id }));
        }
コード例 #3
0
        public ActionResult SelectionSetting(string level_1_id /*selection_id*/)
        {
            object result = SelectionInfoStore.GetSelectionSetting(level_1_id);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }