Add reminder to todo #60

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

Comments

Projects
None yet
3 participants
@codeliner
Member

codeliner commented Feb 17, 2016

  • 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 codeliner added the exercise label Feb 17, 2016

@codeliner

This comment has been minimized.

Show comment
Hide comment
@codeliner

codeliner Feb 17, 2016

Member

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.

Member

codeliner commented Feb 17, 2016

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

This comment has been minimized.

Show comment
Hide comment
@rommsen

rommsen Mar 3, 2016

Contributor

I will try to do this

Contributor

rommsen commented Mar 3, 2016

I will try to do this

@prolic

This comment has been minimized.

Show comment
Hide comment
@prolic

prolic Mar 3, 2016

Member

👍

Member

prolic commented Mar 3, 2016

👍

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