public async Task <VotationDto> Handle(GetVotationByIdQuery request, CancellationToken cancellationToken) { var votation = await _service.GetVotationById(request.VotationId); if (votation == null) { throw new NotFoundException("Votación no encontrada", request.VotationId); } return(votation); }
public async Task <VoteDto> Handle(GetVotesCountByVotationIdQuery request, CancellationToken cancellationToken) { var votation = await _votationService.GetVotationById(request.VotationId); if (votation == null) { throw new ErrorException("05", "La votación solicitada no existe"); } var voteCountInfo = _mapper.Map <VoteDto>(votation); var candidateVoteInfo = await _service.CountVotes(request.VotationId); if (candidateVoteInfo == null || candidateVoteInfo.Count == 0) { throw new ErrorException("06", "No se realizaron votos"); } voteCountInfo.VotesCount = candidateVoteInfo; return(voteCountInfo); }