public Task <bool> Handle(RegisterNewTransactionStatusCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var transactionType = new TransactionStatus(message.Id, message.Name);

            if (_transactionStatusRepository.GetByName(message.Name) != null)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "The transactionType name has already been taken."));
                return(Task.FromResult(false));
            }

            _transactionStatusRepository.Add(transactionType);

            if (Commit())
            {
                Bus.RaiseEvent(new TransactionStatusRegisteredEvent(transactionType.Id, transactionType.Name));
            }

            return(Task.FromResult(true));
        }
Esempio n. 2
0
        public TransactionStatus GetItemStatus(string configName)
        {
            // pegar informacoes do status
            TransactionStatus itemStatus = _transactionStatusRepository
                                           .GetByName(configName);

            return(itemStatus);
        }
Esempio n. 3
0
 public TransactionStatusViewModel GetByName(string name)
 {
     return(_mapper.Map <TransactionStatusViewModel>(_TransactionStatusRepository.GetByName(name)));
 }