Ejemplo n.º 1
0
        public async Task UpdateSongAsync(int albumId, int songId, CreateUpdateSongDto updatedSongModel)
        {
            var existingSong = await _songRepository.GetSongAsync(albumId, songId);

            var updatedSong = _mapper.Map(updatedSongModel, existingSong);
            await _songRepository.UpdateSongAsync(updatedSong);
        }
Ejemplo n.º 2
0
        public async Task <SongDto> AddSongAsync(int albumId, CreateUpdateSongDto newSong)
        {
            var song = _mapper.Map <Song>(newSong);
            await _songRepository.AddSongAsync(albumId, song);

            return(_mapper.Map <SongDto>(song));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Put(int albumId, int songId, [FromBody] CreateUpdateSongDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _songService.UpdateSongAsync(albumId, songId, model);

            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Post(int albumId, [FromBody] CreateUpdateSongDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var song = await _songService.AddSongAsync(albumId, model);

            return(Created($"api/album/{albumId}/song/{song.Id}", null));
        }