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 }); }
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}")); } }
public async Task <Votes> Get() => await _votes.GetVotes();