Beispiel #1
0
        string AddChannelTag()
        {
            //检查是否已经存在改标签
            List <string> tagsList = ChannelHelper.GetTags(ObjectID);

            if (tagsList != null && tagsList.Contains(TagName))
            {
                return("{\"success\":false,\"msg\":\"该标签已经存在!\"}");
            }
            else
            {
                Channel a = ChannelHelper.GetChannelById(ObjectID);
                if (a != null)
                {
                    //更新文章标签
                    a.Tags = a.Tags + "'" + TagName + "'";

                    try
                    {
                        ChannelHelper.UpdateChannel(a, new string[] { "Tags" });

                        //更新标签使用频率

                        TagsHelper.Add(TagName);
                    }
                    catch (Exception ex)
                    {
                        return("{\"success\":false,\"msg\":\"" + ex.Message + "\"}");
                    }

                    //记录日志
                    AddLog("编辑文章", string.Format("为栏目【{0}】增加标签【{1}】", a.Title, TagName));


                    return("{\"success\":true,\"msg\":\"添加成功!\"}");
                }
                return("{\"success\":false,\"msg\":\"文章已被删除!\"}");
            }

            return("");
        }