示例#1
0
 private void Fill(Ariticle ariticle)
 {
     this.Title = ariticle.Title;
     this.UGC = ariticle.UGC;
     this.Tags = new List<string>();
     foreach (var item in ariticle.Tags)
     {
         this.Tags.Add(item.Title);
     }
 }
示例#2
0
        public async Task <ActionResult <Ariticle> > Post([FromBody] ArticleRequest req)
        {
            var item = new Ariticle()
            {
                ArticleUrl    = req.ArticleUrl,
                Author        = req.Author,
                EosAccount    = req.Account,
                State         = 0,
                Time          = DateTime.Now,
                Title         = req.Title,
                TransactionId = req.TransactionId
            };


            _context.Ariticle.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtRoute("", new { id = item.Id }, item));
        }
示例#3
0
        //当数据源为SQL时调用 
        //ModeType: "view", IsLoadLeaf: isLoadLeaf, NodeId: pId, XmlUrl: xmlUrl
        //public ActionResult GetTreeByRootId(string ModeType, string IsLoadLeaf, string NodeId)
        //{

        //    Tree tree = new Tree("开发技术");
        //    string result = "";
        //    if (NodeId != "")
        //    {
        //        int rootId = Int32.Parse(NodeId);
        //        List<TreeNode> list = tree.GetTreeNodeChild(rootId);
        //        result = JsonConvert.SerializeObject(list);
        //    }
        //    else
        //    {
        //        //"[{\"Ariticle\":null,\"Id\":6,\"Title\":\"Html\",\"Deepth\":2,\"ParentId\":1,\"IsLeaf\":true}]
        //        result = "[{\"Ariticle\":\"null\",\"Id\":\"" + tree.RootNode.Id + "\",\"Title\":\"" + tree.RootNode.Title + "\",\"Deepth\":\"" + tree.RootNode.Deepth + "\",\"ParentId\":\"null\",\"IsLeaf\":\"" + tree.RootNode.IsLeaf + "\"}]";
        //        //result = JsonConvert.SerializeObject(result);
        //    }

        //    // List<TreeNode>

        //    return Content(result);
        //}

        public string AddAriticle(string title, string userId, string visibility, string tag, string content, string treeNodeParentId)
        {
            Ariticle ariticle = new Ariticle();
            //添加标题
            ariticle.Title = title;
            //添加内容
            //ariticle.UGC = System.Web.HttpUtility.UrlDecode(content);
            content = System.Web.HttpUtility.UrlDecode(content);
            content = content.Replace("CodeReplacePlus", "+");
            ariticle.UGC = content;
            //ariticle.UGC = content;
            //添加标签
            string[] tlist = tag.Split(new char[] { ',' });
            List<AriticleTag> Tags = new List<AriticleTag>();
            AriticleTag ariticletag = new AriticleTag();
            for (int i = 0; i < tlist.Length; i++)
            {
                ariticletag = new AriticleTag();
                ariticletag.Title = tlist[i];
               // ariticletag.Article = ariticle;
                Tags.Add(ariticletag);
            }
            ariticle.Tags = Tags;
            //创建一个新节点
            TreeNode treeNode = new TreeNode(Int32.Parse(treeNodeParentId), title);
            //创建不可见分组信息数组
            string[] inlist = visibility.Split(new char[] { ';' });
            List<int> visiblityGroup = new List<int>();
            for (int i = 0; i < inlist.Length - 1; i++)
            {
                visiblityGroup.Add(Int32.Parse(inlist[i]));
            }
            AriticleService ariticleService = new AriticleService();
            ariticleService.NewAriticle(ariticle, visiblityGroup,userId,treeNode);
            return "success";
        }
示例#4
0
 public AriticleViewModel(Ariticle ariticle)
 {
     this.Tags = new List<string>();
     this.Fill(ariticle);
 }