Exemple #1
0
        public IActionResult PutAlbum(Guid id, Album album)
        {
            if (id != album.Id)
            {
                return(BadRequest());
            }



            try
            {
                _albumService.Atualizar(album);
            }
            catch (Exception ex)
            {
                if (!AlbumExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> Atualizar(Guid id, AlbumViewModel albumViewModel)
        {
            if (id != albumViewModel.Id)
            {
                return(BadRequest());
            }

            await _albumService.Atualizar(_mapper.Map <Album>(albumViewModel));

            await Commit(_albumRepository);

            if (!OperacaoValida())
            {
                return(CustomBadRequest());
            }

            return(NoContent());
        }
        public async Task <IActionResult> Atualizar(Guid id, AlbumViewModel albumViewModel)
        {
            if (!ModelState.IsValid)
            {
                await PopularSelectList(albumViewModel);

                return(View(albumViewModel));
            }

            var albumResponse = await _albumService.Atualizar(id, albumViewModel);

            if (ResponsePossuiErros(albumResponse.ResponseResult))
            {
                await PopularSelectList(albumViewModel);

                return(View(albumResponse));
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult <AlbumViewModel> > Update(int id, AlbumViewModel albumViewModel)
        {
            if (id != albumViewModel.AlbumId)
            {
                NotifyError("O id informado não é o mesmo que foi informado na query");
                return(CustomResponse(albumViewModel));
            }

            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }

            var album = _mapper.Map <Album>(albumViewModel);

            album.Artista = await _artistaRepository.ObterPorId(album.Artista.ArtistaId);

            await _albumService.Atualizar(album);

            return(CustomResponse(albumViewModel));
        }
Exemple #5
0
 public IActionResult AtualizarAlbum(Album album)
 {
     _albumService.Atualizar(album);
     _session.SetString("Alertas", "Parabéns!!!| Você acabou de atualizar um album.");
     return(RedirectToAction("Index"));
 }