public IActionResult CreateComment(CreateCommentViewModel model)
        {
            Comment comment = new Comment
            {
                CommentText   = model.CommentText,
                LoginUser     = _user.GetUserDB(_userManager.GetUserId(User)).UserName,
                PublicationID = ID,
                Publication   = _publication.GetPostDB(ID)
            };

            _comment.AddCommentDB(comment);
            return(RedirectToAction("Post", "Publication", new { ID }));
        }
Beispiel #2
0
        //public void Hello(int postId) // передаем id комента
        //{
        //    var com = _comment.AllComments(postId); //айди поста

        //    int count = 0;
        //    foreach (var c in com)
        //    {
        //        var likes = _likeService.GetAllLikes(c.Id);
        //        foreach (var item in likes)
        //        {
        //            count += 1;
        //        }
        //        c.polelike = count;

        //    }

        //}


        public Comment CreateComment(CreateCommentViewModel model, int ID, string login)
        {
            Comment comment = new Comment
            {
                CommentText   = model.CommentText,
                LoginUser     = login,//_user.GetUserDB(_userManager.GetUserId(User)).UserName,
                PublicationID = ID,
                Publication   = _publicationService.GetPostDB(ID)
            };

            _comment.AddCommentDB(comment);
            return(comment);
        }