You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a dedicated command for the action called ReopenTodo and put it into the todo command folder
Create a command handler for the new command
Create a factory for the command handler and put it here
The command handler needs to fetch an existing Todo from the TodoList so inject the TodoList as dependency into the command handler using the factory
Make the command handler available in the container by using the command handler FQCN as service name and point it to the factory. See configuration for the PostTodoCommandHandler as an example
The API will translate the request into a command message and dispatch the message on the command bus. The command bus is responsible to locate and invoke the responsible command handler. To do so the command bus also need some route information.
In the command handler you should load the effected Todo from the TodoList
The Todo aggregate root is responsible for handling the action so it needs a new method.
In the method the Todo should check it's current status. Only if it is done it can be marked as open again otherwise it should throw an exception
If the precondition is met the Todo should not change it's state directly but instead record a new domain event called TodoWasReopened
Add a state changing method in the Todo aggregate root based on the new event. Call the method whenTodoWasReopened and require the recorded event as a input parameter then change the TodoStatus to open
The same event needs also be handled by a projector so that the read model gets updated. You already know how to route a command message to a handler. Now do the same for the event and route it to a projector which updates the read model table.
Bonus Points: Write at least one unit test which covers that a done Todo can change its state to open again and records a TodoWasReopened event to track the change.
The text was updated successfully, but these errors were encountered:
Depends on #1
Step By Step Guide
ReopenTodo
and put it into the todo command folderYou can do this in the routes configuration.
TodoWasReopened
whenTodoWasReopened
and require the recorded event as a input parameter then change theTodoStatus
toopen
Bonus Points: Write at least one unit test which covers that a done Todo can change its state to open again and records a
TodoWasReopened
event to track the change.The text was updated successfully, but these errors were encountered: