Exemplo n.º 1
0
        public Task <bool> Handle(RemoveTransactionTypeCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            TransactionType transactionType = _transactionTypeRepository.GetById(message.Id);

            if (transactionType == null)
            {
                // notificar o dominio
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "Registro não encontrado"));

                return(Task.FromResult(false));
            }

            _transactionTypeRepository.Remove(message.Id);

            if (Commit())
            {
                Bus.RaiseEvent(new TransactionTypeRemovedEvent(message.Id));
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 2
0
        public void Remove(Guid id)
        {
            var removeCommand = new RemoveTransactionTypeCommand(id);

            Bus.SendCommand(removeCommand);
        }