public async Task <IActionResult> DeleteConfirmed(int id) { var anuncio = await _anuncioRepository.GetAnuncioPorId(id); await _anuncioRepository.Excluir(anuncio); return(RedirectToAction(nameof(Index))); }
public bool RemoverAnuncio(int anuncioId) { try { var anuncioAtual = _anuncioRepository.Listar().FirstOrDefault(a => a.Id == anuncioId); if (anuncioAtual == null) { Notificar(DomainNotification.DomainNotificationFactory.Criar(DomainNotificationType.BusinessError, "Nenhum anúncio encontrado para exclusão.")); return(false); } _anuncioRepository.Excluir(anuncioAtual); return(Commit("Ocorreu um erro ao tentar remover o anúncio")); } catch (Exception ex) { NotificarException(DomainNotificationType.TechnicalError, ex); return(false); } }
public async Task Executar(int id) { var dadosDoAnuncio = await _anuncioRepository.BuscarPorId(id); await _anuncioRepository.Excluir(dadosDoAnuncio); }