Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reminder to todo #60

Closed
codeliner opened this issue Feb 17, 2016 · 3 comments
Closed

Add reminder to todo #60

codeliner opened this issue Feb 17, 2016 · 3 comments

Comments

@codeliner
Copy link
Member

  • User should be the owner of the todo
  • User should be able to add a reminder as a date in the future to a todo
  • User should not be able to add a reminder, if the date is in the past
@codeliner
Copy link
Member Author

Step By Step Guide

  1. This exercise requires UI changes here. If you're not sure what changes are required just drop us a note in the chat and we'll help you with the UI part.
  2. Create a dedicated command for the action called AddReminderToTodo and put it into the todo command folder
  3. 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
  4. Now you can route the command to its handler
    • Route the http request representing the command to the command handling middleware.
      You can do this in the routes configuration.
    • The middleware 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.
  5. In the command handler you should load the effected Todo from the TodoList
  6. Implement a AddReminderToTodo::reminder method that returns a TodoReminder value object. See TodoDeadline and AddDeadlineToTodo as an example.
  7. 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 open a reminder can be added otherwise it should throw an exception
    • If the preconditions are met the Todo should not change its state directly but instead record a new domain event called ReminderWasAddedToTodo
    • Add a state changing method in the Todo aggregate root based on the new event. Call the method whenReminderWasAddedToTodo and require the recorded event as input parameter. Pull the TodoReminder value object from the event and add it to the Todo.
  8. 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 read_todo. The read table needs to be aligned. Add a new migration class and in the migration add a new column called "reminder" to the table.

Bonus Points: Write at least one unit test which covers that a reminder can be added to a Todo.

@rommsen
Copy link
Contributor

rommsen commented Mar 3, 2016

I will try to do this

@prolic
Copy link
Member

prolic commented Mar 3, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants