Exemplo n.º 1
0
        public Blog Save(string id, string owner, string title, string keywords, string data, params string[] categories)
        {
            Blog blog = Get(id);
            using (IConnectinContext cc = DBContext.DB1)
            {
                cc.BeginTransaction();
                if (blog == null)
                {
                    blog = new Blog();
                    blog.Owner = owner;
                }
                blog.Title = title;
                blog.Keywords = keywords;
                blog.Content = data;
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(data);
                blog.Summary = doc.DocumentNode.InnerText;
                blog.Summary = blog.Summary.Substring(0, blog.Summary.Length > 300 ? 300 : blog.Summary.Length);
                blog.Save();
                (BlogLinkCategory.blog == id).Delete<BlogLinkCategory>();
                foreach (string item in categories)
                {
                    BlogLinkCategory blc = new BlogLinkCategory();
                    blc.Blog = blog.ID;
                    blc.Category = item;
                    blc.Save();
                }
                cc.Commit();
            }

            return blog;
        }
Exemplo n.º 2
0
 public ActionResult savepost(string id, string title, string data, string keywords, string categories)
 {
     string[] cates = categories.Split(',');
     ikende.minicms.web.Service.Model.Blog blog = BlogService.Save(id, Core.Utils.Loginer.Name, title, keywords, data, cates);
     return(new StringResult(blog.ID));
 }