public VoteResult Upvote(int commentId, int userId)
        {
            var comment = _context.Comments.Include(x => x.Thread)
                          .Include(x => x.Parent)
                          .Include(x => x.User)
                          .Include(v => v.Votes).ThenInclude(u => u.VoteBy)
                          .FirstOrDefault(x => x.CommentId == commentId);

            var user = _context.Users.First(x => x.UserId == userId);

            var vote = comment.Votes.FirstOrDefault(x => x.VoteBy.UserId == user.UserId);

            if (vote == null)
            {
                vote = new DAL.Entities.CommentVote
                {
                    VoteScore = 1,
                    VoteBy    = user
                };

                comment.Votes.Add(vote);
            }
            else
            {
                vote.VoteScore = vote.VoteScore == 1 ? 0 : 1;
            }

            _context.SaveChanges();

            return(new VoteResult()
            {
                Score = comment.Votes.Sum(x => x.VoteScore),
                DidScoreIncrease = vote.VoteScore == 1,
            });
        }
        public void CreateComment(string content, Comment parentComment, User user, Thread thread)
        {
            var entityComment = _mapper.Map <DAL.Entities.Comment>(parentComment);
            var entityUser    = _mapper.Map <DAL.Entities.User>(user) ?? throw new Exception("User cannot be null");
            var entityThread  = _mapper.Map <DAL.Entities.Thread>(thread) ?? throw new Exception("Thread cannot be null");

            var newComment = new DAL.Entities.Comment()
            {
                Thread   = entityThread,
                User     = entityUser,
                Content  = content,
                Parent   = entityComment,
                Created  = DateTime.Now,
                Modified = DateTime.Now,
                Votes    = new List <CommentVote>()
            };

            _context.Comments.Add(newComment);

            var comment = new DAL.Entities.CommentVote()
            {
                VoteScore = 1,
                VoteBy    = entityUser
            };

            newComment.Votes.Add(comment);

            _context.SaveChanges();
        }