示例#1
0
文件: BlogDao.cs 项目: mikeqian/blogs
        public static Blog Update(Blog blog)
        {
            using (var cnn = ConnectionManager.GetConnection())
            {
                cnn.Open();
                cnn.Execute("Update Blog set Summary=@Summary,CreateTime=@CreateTime,Title=@Title,Content=@Content WHERE ID=@ID", blog);

                return blog;
            }
        }
示例#2
0
文件: BlogDao.cs 项目: mikeqian/blogs
        public static Blog Create(Blog blog)
        {
            using (var cnn = ConnectionManager.GetConnection())
            {
                cnn.Open();
                cnn.Execute("Insert into Blog (ID,Summary,Title,Content,CreateTime) VALUES (@ID,@Summary,@Title,@Content,@CreateTime)", blog);

                return blog;
            }
        }
示例#3
0
        public void TestAddBlog()
        {
            BlogDao.Delete("0fd98278b1a549638556ca029b1dffe8");
            BlogDao.Delete("3b5df9babcc64ec4a49599e10272c365");

            var blog = new Blog();
            blog.Summary = "";
            blog.CreateTime = DateTime.Now;
            blog.ID = Guid.NewGuid().ToString("N");

            BlogDao.Create(blog);

            blog.Summary = "<p>&nbsp;&nbsp;直接抢劫了现成的模板,在网络上挖上一个专属自己的坑。</p>";
            BlogDao.Update(blog);

            BlogDao.Delete(blog.ID);
        }
示例#4
0
        public object EditBlog(Blog blog)
        {
            if (blog != null && !string.IsNullOrWhiteSpace(blog.Content))
            {
                var text = System.Text.RegularExpressions.Regex.Replace(blog.Content, @"<[^>]*>", "");
                if (text.Length > 100)
                {
                    text = text.Substring(0, 100);
                }

                blog.Summary = text;
                blog.CreateTime = DateTime.Now;

                BlogManager.UpdateBlog(blog);

                return new JsonResponseModel { Success = true };
            }
            else
            {
                return new JsonResponseModel { Success = false };
            }
        }
示例#5
0
 public static void UpdateBlog(Blog blog)
 {
     BlogDao.Update(blog);
 }
示例#6
0
 public static void AddBlog(Blog blog)
 {
     BlogDao.Create(blog);
 }