Exemplo n.º 1
0
        public async Task <ActionResult <CommentVoteResponseModel> > Vote(CommentVoteInputModel input)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            await this.commentsVotesService.UserCommentVoteAsync(input.CommentNumber, input.IsUpVote, userId);

            var commentLikesAndDislikes = this.commentsVotesService.GetCommentVotes(input.CommentNumber);

            return(commentLikesAndDislikes);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <ResponseVoteModel> > Comment([FromBody] CommentVoteInputModel input)
        {
            if (this.User.Identity.IsAuthenticated)
            {
                if (await this.commentsService.DoesCommentExistAsync(input.CommentId))
                {
                    var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                    var status = await this.commentsService.CommentVoteAsync(input.CommentId, userId, input.IsUpvote);

                    return(new ResponseVoteModel()
                    {
                        Status = status
                    });
                }

                return(this.NotFound());
            }

            return(this.Unauthorized());
        }