Yorro is right where to place the DTO, but I urge you to avoid "thinking DTO." This way of thinking interferes with DDD thinking.
The thought of βI need a DTO hereβ is thinking of a technical presentation (as plalx says); this level of abstraction is too low. Try a higher level of abstraction and think about your domain, user tasks, and user interface.
Need to get viewing data for a user? Connect it to the user interface through a view service that returns a specific YourViewInfo class.
Need to send data to a service to complete a task? Send it a specific TaskMessageInfo class or a specific class of commands.
When you start modeling the interiors of these classes, you should start thinking about your technical background; then you can come to the conclusion, which may be, for example, DTO classes for convenience.
Thinking in this way helps to model the system and does not raise questions such as
Where to put this thing?
source share