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); }
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)); }
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(); }