Ejemplo n.º 1
0
        public async Task <ActionResult <VoteResponseModel> > Post(VoteInputModel input)
        {
            var userId = _userManager.GetUserId(User);
            await _votesService.VoteAsync(input.CommentId, userId, input.IsUpVote);

            var votesScore = _votesService.GetVotes(input.CommentId);

            return(new VoteResponseModel {
                VotesCount = votesScore
            });
        }
Ejemplo n.º 2
0
 public ActionResult <IEnumerable <VoteModel> > GetVotes(int tableId)
 {
     try
     {
         return(Ok(_voteService.GetVotes(tableId)));
     }
     catch (NotFoundOperationException ex)
     {
         return(NotFound(ex.Message));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, $"Something happend: {ex.Message}"));
     }
 }
Ejemplo n.º 3
0
 public async Task <Votes> Get() => await _votes.GetVotes();