public override async Task <List <PlaylistDto> > Handle(GetPlaylistsForUserQuery query, CancellationToken cancellationToken) { var playlists = await _repository.FindListAsync(pl => pl.UserId == query.UserId); var playlistDtos = _playlistMapper .MapToPlaylistDtoEnumerable(playlists) .ToList(); return(playlistDtos); }
public async Task <IActionResult> GetPlaylists() { var query = new GetPlaylistsForUserQuery { UserId = _accountService.UserId }; var playlists = await _mediator.Send(query); var playlistsCleaned = playlists.Select(pl => new { pl.Id, pl.Name }); return(Ok(playlistsCleaned)); }