public ActionResult AddComment(string commentMessage, int postId)
        {
            //  можливо краще використати авто-маппер
            var newComment = new CommentServiceReference.CommentDto();
            newComment.Message = commentMessage;
            newComment.AuthorId = _authProvider.CurrentUserId;
            newComment.DatePosted = DateTime.Now;
            newComment.PostId = postId;
            _commentService.Add(newComment);

            var postCommentsViewModel = new PostCommentsViewModel();
            postCommentsViewModel.PostComments = _commentService.GetByPostId(postId);
            postCommentsViewModel.PostId = postId;

            if (Request.IsAjaxRequest())
            {
                return PartialView("PostCommentsPartial", postCommentsViewModel);
            }
            return View("PostCommentsPartial", postCommentsViewModel);
        }
Exemplo n.º 2
0
        public ActionResult AddComment(string commentMessage, int postId)
        {
            //  можливо краще використати авто-маппер
            var newComment = new CommentServiceReference.CommentDto();

            newComment.Message    = commentMessage;
            newComment.AuthorId   = _authProvider.CurrentUserId;
            newComment.DatePosted = DateTime.Now;
            newComment.PostId     = postId;
            _commentService.Add(newComment);

            var postCommentsViewModel = new PostCommentsViewModel();

            postCommentsViewModel.PostComments = _commentService.GetByPostId(postId);
            postCommentsViewModel.PostId       = postId;

            if (Request.IsAjaxRequest())
            {
                return(PartialView("PostCommentsPartial", postCommentsViewModel));
            }
            return(View("PostCommentsPartial", postCommentsViewModel));
        }