public Task <bool> Handle(RemoveCardBrandCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } CardBrand cardBrand = _cardBrandRepository.GetById(message.Id); if (cardBrand == null) { // notificar o dominio Bus.RaiseEvent(new DomainNotification(message.MessageType, "Registro não encontrado")); return(Task.FromResult(false)); } _cardBrandRepository.Remove(message.Id); if (Commit()) { Bus.RaiseEvent(new CardBrandRemovedEvent(message.Id)); } return(Task.FromResult(true)); }
public void Remove(Guid id) { var removeCommand = new RemoveCardBrandCommand(id); Bus.SendCommand(removeCommand); }