public async Task <bool> Handle(RemoverFuncaoCommand message, CancellationToken cancellationToken) { if (!message.EhValido()) { await NotificarErrosValidacao(message); return(false); } var funcaoDatabase = _funcaoRepository.GetById(message.Data.Id); if (funcaoDatabase == null) { await _mediatorHandler.PublicarNotificacao(new DomainNotification(message.MessageType, $"A função com o Id {message.Data.Id} não foi localizado!")); return(false); } _funcaoRepository.Remove(message.Data.Id); var success = await Commit(); if (success) { await _mediatorHandler.PublicarEvento(new Events.Funcao.FuncaoRemovidaEvent(message.Data)); } return(true); }
public void Delete(int idFuncao) { try { var Funcao = dbFuncao.GetById(idFuncao); dbFuncao.Remove(Funcao); } catch (Exception ex) { throw new Exception($"Erro ao excluir Funcao: {ex.Message}."); } }