예제 #1
0
        public ActionResult UpdateSong(int id, SongUpdateDto songUpdateDto)
        {
            var songModelFromRepo = _repository.GetSongById(id);

            if (songModelFromRepo == null)
            {
                return(NotFound());
            }

            _mapper.Map(songUpdateDto, songModelFromRepo);

            _repository.UpdateSong(songModelFromRepo);

            _repository.SaveChanges();

            return(NoContent());
        }
예제 #2
0
        public IActionResult UpdateSong(Guid ID, [FromBody] SongUpdateDto updateDto)
        {
            var repoSong = _songRepository.GetSingle(ID);

            if (repoSong == null)
            {
                return(NotFound());
            }

            Mapper.Map(updateDto, repoSong);

            _songRepository.Update(repoSong);

            bool result = _songRepository.Save();

            if (!result)
            {
                return(new StatusCodeResult(500));
            }

            return(Ok(Mapper.Map <SongDto>(repoSong)));
        }