コード例 #1
0
            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);
            }
コード例 #2
0
            public async Task <VoterDto> Handle(GetVoterByIdQuery request, CancellationToken cancellationToken)
            {
                var voterFromDb = await _voterRepository.FindAsync(request.Id);

                var voterAfterMappingToReturn = _mapper.Map <VoterDto>(voterFromDb);

                return(voterAfterMappingToReturn);
            }
コード例 #3
0
            public async Task <Unit> Handle(DeleteVoterCommand request, CancellationToken cancellationToken)
            {
                var voterToDelete = await _voterRepository.FindAsync(request.VoterId);

                _voterRepository.Delete(voterToDelete);


                return(Unit.Value);
            }