Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            string tagName     = context.Request["name"],
                   tagType     = context.Request["type"],
                   accessLevel = context.Request["level"];

            if (string.IsNullOrEmpty(tagName))
            {
                resp.errcode = (int)APIErrCode.PrimaryKeyIncomplete;
                resp.errmsg  = "请输入标签名称";
                bllTag.ContextResponse(context, resp);
                return;
            }
            ZentCloud.BLLJIMP.Model.MemberTag tag = new ZentCloud.BLLJIMP.Model.MemberTag();
            tag.TagType      = string.IsNullOrWhiteSpace(tagType) ? "all" : tagType;
            tag.TagName      = tagName;
            tag.AccessLevel  = string.IsNullOrWhiteSpace(accessLevel) ? 0 : Convert.ToInt32(accessLevel);
            tag.CreateTime   = DateTime.Now;
            tag.Creator      = currentUserInfo.UserID;
            tag.WebsiteOwner = bllTag.WebsiteOwner;
            if (bllTag.ExistsTag(tag))
            {
                resp.errcode = (int)APIErrCode.IsRepeat;
                resp.errmsg  = "标签不能重复添加";
                bllTag.ContextResponse(context, resp);
                return;
            }

            if (bllTag.AddTag(tag))
            {
                resp.errcode   = (int)APIErrCode.IsSuccess;
                resp.isSuccess = true;
            }
            else
            {
                resp.errcode = (int)APIErrCode.OperateFail;
                resp.errmsg  = "添加失败";
            }

            bllTag.ContextResponse(context, resp);
        }
Пример #2
0
        /// <summary>
        /// 添加标签
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddTag(HttpContext context)
        {
            string tagName = context.Request["TagName"],
                   tagType = context.Request["TagType"];

            if (string.IsNullOrEmpty(tagName))
            {
                resp.Status = 0;
                resp.Msg    = "请输入标签名称";
                return(Common.JSONHelper.ObjectToJson(resp));
            }
            MemberTag tag = new MemberTag();

            tag.TagType      = string.IsNullOrEmpty(tagType) ? "all" : tagType;
            tag.TagName      = tagName;
            tag.CreateTime   = DateTime.Now;
            tag.Creator      = this.currentUserInfo.UserID;
            tag.WebsiteOwner = bllTag.WebsiteOwner;
            if (bllTag.ExistsTag(tag))
            {
                resp.Status = 0;
                resp.Msg    = "标签不能重复添加";
                return(Common.JSONHelper.ObjectToJson(resp));
            }

            if (bllTag.AddTag(tag))
            {
                resp.Status = 1;
                resp.Msg    = "添加成功";
            }
            else
            {
                resp.Status = 0;
                resp.Msg    = "添加失败";
            }

            return(Common.JSONHelper.ObjectToJson(resp));
        }