예제 #1
0
        public List <PostComment> GetComments()
        {
            List <PostComment> ls = new List <PostComment>();
            var list = db.Comments.ToList();

            foreach (var item in list)
            {
                var posted = new PostComment()
                {
                    Id       = item.id,
                    comment1 = item.comment1,


                    postId = item.postId,
                    UserId = item.UserId
                };
                ls.Add(posted);
            }
            return(ls);
        }
예제 #2
0
        public bool PostComment(PostComment postComment)
        {
            try
            {
                var comment = new Comment()
                {
                    comment1 = postComment.comment1,

                    postId = postComment.postId,

                    UserId = postComment.UserId
                };
                db.Comments.Add(comment);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }