예제 #1
0
        public async Task <MusicResponse> Handle(GetMusicByIdQuery request, CancellationToken cancellationToken)
        {
            var music = await _musicRepository.FindMusicById(request.Id);

            var response = MusicMapper.Mapper.Map <MusicResponse>(music);

            return(response);
        }
예제 #2
0
        public async Task <MusicResponse> Handle(UpdateMusicCommand request, CancellationToken cancellationToken)
        {
            var updateMusic = await _musicRepository.FindMusicById(request.Id);

            updateMusic.Name     = request.Name;
            updateMusic.ArtistId = request.ArtistId;
            await _musicRepository.UpdateAsync(updateMusic);

            return(MusicMapper.Mapper.Map <MusicResponse>(updateMusic));
        }
예제 #3
0
        public async Task <MusicResponse> Handle(DeleteMusicCommand request, CancellationToken cancellationToken)
        {
            var deleteMusic = await _musicRepository.FindMusicById(request.Id);

            if (deleteMusic != null)
            {
                await _musicRepository.DeleteAsync(deleteMusic);

                return(MusicMapper.Mapper.Map <MusicResponse>(deleteMusic));
            }

            throw new NotImplementedException();
        }