示例#1
0
        private static void EditComment(CommentPoco comment)
        {
            Console.Write("Edit comment(Type 'done' when you are done):");

            string commentContent = string.Empty;

            bool creatingComment = true;

            while (creatingComment)
            {
                string line = Console.ReadLine();
                if (line?.ToLowerInvariant().Trim() == "done")
                {
                    creatingComment = false;
                }
                else
                {
                    commentContent += line;
                }
            }

            using (var conn = new NpgsqlConnection(ConnectionString))
            {
                var database = new Database(conn);
                var service  = new Service(database);
                comment.Content = commentContent;
                service.UpdateComment(comment);
            }

            Console.WriteLine("Great you edited this comment!\n");
        }
示例#2
0
        public void CreateComment(string authorName, string content, int postId, int userId)
        {
            var commentPoco = new CommentPoco
            {
                AuthorName = authorName,
                Content    = content,
                PostId     = postId,
                UserId     = userId
            };

            this.Database.Update(commentPoco);
        }
示例#3
0
 public void UpdateComment(CommentPoco poco)
 {
     this.Database.Update(poco);
 }