Пример #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
            });
        }
Пример #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}"));
     }
 }
Пример #3
0
 public async Task <Votes> Get() => await _votes.GetVotes();