示例#1
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var anuncio = await _anuncioRepository.GetAnuncioPorId(id);

            await _anuncioRepository.Excluir(anuncio);

            return(RedirectToAction(nameof(Index)));
        }
示例#2
0
        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);
            }
        }
示例#3
0
        public async Task Executar(int id)
        {
            var dadosDoAnuncio = await _anuncioRepository.BuscarPorId(id);

            await _anuncioRepository.Excluir(dadosDoAnuncio);
        }