Exemplo n.º 1
0
        public static void Init(ArticleContext context)
        {
            if (!context.Comments.Any())
            {
                context.Comments.AddRange(

                    new Comment {
                    ParentCommentId = 0,
                    CommentText     = "New comment",
                    Author          = "Yan Pershay",
                    CommentDate     = DateTime.Now
                }
                    );
            }

            context.SaveChanges();
        }
 public void CreateComment(Comment comment)
 {
     comment.CommentDate = DateTime.Now;
     _context.Comments.Add(comment);
     _context.SaveChanges();
 }