Exemple #1
0
        public static bool InsertComment(Comment comment)
        {
            using (var mongo=Mongo.Create(@"mongodb://localhost/test"))
            {
                var commentCollection=mongo.GetCollection<Comment>();

                commentCollection.Insert(comment);
            }

            return true;
        }
Exemple #2
0
 public void TestInsertComment()
 {
     for (int i=1;i<=50;i++)
     {
         Comment comment=new Comment()
         {
             AuthorId=1,
             AuthorName="admin",
             Content="这是测试信息<br />这是测试信息"+i,
             //Id=ObjectId.NewObjectId(),
             PostId=1,
         };
         CommentFarm.InsertComment(comment);
         Console.WriteLine("Comment {0} was insert successful!",i);
     }
 }
Exemple #3
0
 public ActionResult Comment(int postId)
 {
     if (Session["Name"]!=null)
     {
         if (Request.Form["message"]!=null || Request.Form["message"]!="" )
         {
             Comment comment=new Comment()
             {
                 Content=Request.Form["message"].ToString(),
                     //.Replace("<","&lt;").Replace(">","&gt;").Replace("\r\n","<br />").Replace("\n","<br />"),
                 AuthorId=int.Parse(Session["Id"].ToString()),
                 AuthorName=Session["Name"].ToString(),
                 PostId=postId,
                 CommentDate=DateTime.Now,
             };
             CommentFarm.InsertComment(comment);
         }
     }
     return Redirect("/blog/"+postId+"/");
 }