Ejemplo n.º 1
0
        public virtual async Task <TblPostComments> PrepareTblCommentsAsync(CommentEditorModel model, string currentUserId, bool published)
        {
            TblPostComments parentComment = null;

            if (model.ReplyToCommentId != null)
            {
                parentComment = await _commentsService.FindByIdAsync(model.ReplyToCommentId.Value);
            }

            var result = new TblPostComments()
            {
                Comment              = model.Comment,
                CommentDate          = DateTime.Now,
                NotifyWhenNewComment = model.NotifyWhenNewComment,
                NotifyWhenReply      = model.NotifyWhenReply,
                PostId          = model.PostId,
                UserEmail       = model.UserEmail,
                UserName        = model.UserName,
                UserId          = currentUserId,
                Published       = published,
                ParentCommentId = parentComment?.Id,
                Quote           = parentComment?.Comment
            };

            return(result);
        }
        public virtual async Task <ActionResult> Update(TblPostComments value)
        {
            var comment = await _commentsService.FindByIdAsync(value.Id);

            comment.Comment     = value.Comment;
            comment.CommentDate = value.CommentDate;
            await _commentsService.UpdateAsync(comment);

            return(Json(value, JsonRequestBehavior.AllowGet));
        }