コード例 #1
0
        public Task <bool> Handle(RemoveCardTypeCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            CardType cardType = _cardTypeRepository.GetById(message.Id);

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

                return(Task.FromResult(false));
            }

            _cardTypeRepository.Remove(message.Id);

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

            return(Task.FromResult(true));
        }
コード例 #2
0
        public void Remove(Guid id)
        {
            var removeCommand = new RemoveCardTypeCommand(id);

            Bus.SendCommand(removeCommand);
        }