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; } }
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; } }
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> 直接抢劫了现成的模板,在网络上挖上一个专属自己的坑。</p>"; BlogDao.Update(blog); BlogDao.Delete(blog.ID); }
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 }; } }
public static void UpdateBlog(Blog blog) { BlogDao.Update(blog); }
public static void AddBlog(Blog blog) { BlogDao.Create(blog); }