예제 #1
0
        public ActionResult CreateComment(string commentId, CommentModel newComment)
        {
            var userId = User.Identity.GetUserId();
            var user   = UserManager.FindById(userId);

            newComment.CreatorId            = userId;
            newComment.Voters               = new HashSet <string>();
            newComment.Fullname             = user.FirstName + " " + user.LastName;
            newComment.CreatedByCurrentUser = true;

            var comment = _commentManager.GetCommentById(commentId);

            comment.Comments.Add(newComment);
            _commentManager.UpdateComment(comment);
            return(Json(ConvertToJsonCommentModel(newComment)));
        }
        public void UpdateCommentSuccess()
        {
            Guid    id      = CommentDB.GetCommentsByPostId(active, post_id)[0].Id;
            Comment comment = new Comment
            {
                TextComment = "updated text comment",
                UserId      = "user_1",
                PostId      = "post_1",
                Active      = true
            };
            Comment updatedComment = CommentDB.UpdateComment(comment, id);

            Assert.AreEqual(comment.TextComment, updatedComment.TextComment);
        }
        public void UpdateCommentFailed()
        {
            Guid    id      = CommentDB.GetCommentsByPostId(active, post_id)[0].Id;
            Comment comment = new Comment
            {
                TextComment = "",
                UserId      = "user_1",
                PostId      = "post_1",
                Active      = true
            };
            Comment updatedComment = CommentDB.UpdateComment(comment, id);

            Assert.IsNull(updatedComment);
        }
        public void UpdateCommentFailed()
        {
            int     id      = CommentDB.GetCommentsByPostId(active, 3)[0].Id;
            Comment comment = new Comment
            {
                Text       = "",
                Date       = new DateTime(2018, 2, 1, 5, 0, 0),
                Attachment = Encoding.ASCII.GetBytes("dodatak"),
                PostId     = 3,
                UserId     = 2,
                Active     = true
            };
            Comment updatedComment = CommentDB.UpdateComment(comment, id);

            Assert.IsNull(updatedComment);
        }
        public void UpdateCommentSuccess()
        {
            int     id      = CommentDB.GetCommentsByPostId(active, 3)[0].Id;
            Comment comment = new Comment
            {
                Text       = "UPDATE",
                Date       = new DateTime(2018, 2, 1, 5, 0, 0),
                Attachment = Encoding.ASCII.GetBytes("dodatak"),
                PostId     = 3,
                UserId     = 2,
                Active     = true
            };
            Comment updatedComment = CommentDB.UpdateComment(comment, id);

            Assert.AreEqual(comment.Text, updatedComment.Text);
        }
 public Comment UpdateComment([FromBody] Comment comment, int id)
 {
     return(CommentDB.UpdateComment(comment, id));
 }