n3m05
n3m05

Reputation: 51

CQRS, Wpf + UI Refresh

my company is creating a new software for product selling. We decide to use the DDD+CQRS infrastructure and WPF for the presentation layer, but I don't know how my UI will be notified when an event is raised. 1) Question: - The Operator click "Register" button to save an Order. - My ViewModel send a RegisterOrderCommand to the Command Bus - A "RegisterOrderCommandHandler" manages the command - An OrderAggregateRoot in the Domain Layer registers the order. - A Domain Event "RegisterOrderEvent" is sent to the Event Bus.

How I can notify my UI that the operation is completed? Is it correct that my ViewModel registers an EventHandler to manage an event in the Domain Layer?

2) Question: Is similar to the first one. I've an external device that want to communicate with me. Where I've to place the listener? In the domain layer, in the application layer or in the infrastructure layer?

Thanks

Upvotes: 4

Views: 1247

Answers (1)

Eduardo Brites
Eduardo Brites

Reputation: 4776

1) It depends whether your sending your commands sync or async. In the first case you can send the command inside a try catch block letting the command handler throw an exception if the command is invalid. In the second case I'm afraid you have only 2 options:

a) to assume that the command is always successfull

b) to create a failedevent which is handled by an eventhandler from the read side and deal with it accordingly at UI level.

2) Certainly not in the domain layer. I would put the listener on the infrastructure layer (agnostic to the application/business logic), and I would have a service in the Application layer that uses that listener for obtaining the data from the external device.

Upvotes: 0

Related Questions