Exemplo n.º 1
0
        public async Task <IActionResult> AddSongToPlaylist([FromQuery] int playlistId, [FromBody] SongDto songDto)
        {
            int userId = ClaimHelper.FindNameIdentifier(HttpContext.User.Claims);

            var song = _mapper.Map <SongDto, Song>(songDto);

            var response = await _songService.AddSongToPlaylist(userId, playlistId, song);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }

            songDto = _mapper.Map <Song, SongDto>(response.Resource);

            return(Ok(songDto));
        }