public async Task <Unit> Handle(UpdateVoterCommand request, CancellationToken cancellationToken) { var voterFromDb = await _voterRepository.FindAsync(request.VoterId); await _voterRepository.UpdateAgeAsync(request.VoterId, request.VoterForUpdateDto.Age); return(Unit.Value); }
public async Task <VoterDto> Handle(GetVoterByIdQuery request, CancellationToken cancellationToken) { var voterFromDb = await _voterRepository.FindAsync(request.Id); var voterAfterMappingToReturn = _mapper.Map <VoterDto>(voterFromDb); return(voterAfterMappingToReturn); }
public async Task <Unit> Handle(DeleteVoterCommand request, CancellationToken cancellationToken) { var voterToDelete = await _voterRepository.FindAsync(request.VoterId); _voterRepository.Delete(voterToDelete); return(Unit.Value); }