示例#1
0
 public static Comment[] CreateManyComments(int numberOfComments, NewsPost post)
 {
     var comments = new List<Comment>();
     for (int i = 0; i < numberOfComments; i++)
     {
         var comment = new Comment()
                           {
                               CommentIp = "127.0.0.1",
                               Name = "Daniel" + i,
                               Text = "Hello World " + i,
                               ParentPost = post,
                               Time = DateTime.MinValue
                           };
         comment.SaveAndFlush();
         comments.Add(comment);
     }
     return comments.ToArray();
 }
示例#2
0
 public ActionResult AddComment(Comment comment)
 {
     if (ModelState.IsValid)
     {
         _comments.Add(comment);
         return Content("Success");
     }
     return Content("Error");
 }