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

[Question] Complicated Contracts #40

Open
cwistedt opened this issue Jul 24, 2024 · 1 comment
Open

[Question] Complicated Contracts #40

cwistedt opened this issue Jul 24, 2024 · 1 comment

Comments

@cwistedt
Copy link

Hi Amichai,

Love your template and is trying i out for myself (without MediatR for now). I ran into an "issue" that i dont have a good approach to.
If the Request Object in the Commands solution is a more complicated Object, like one that has a property with a list of custom objects.
How would you pass that list to the command? Would you:

  • Just pass along the entire request object to the command (i assume this is bad practice since Commands belong to the Presentation layer)
  • Create a custom intermediate model in the Application layer and map the list of custom objects to that one (i went with this one for now)
  • Skip the contract and Let the Caller of the api provide the actual command
  • Rethink the presentation layer to have api endpoint with a smaller contract
  • Something else?

My solution for context (i am talking about the list if Items):

The Api
image

The Contract
Screenshot from 2024-07-24 07-35-40

@xavierjohn
Copy link

I also face this challenge. According to best practices, domain objects should remain valid at all times. While it's convenient to place DTOs in the domain layer to facilitate conversion at the application layer and streamline command creation, this approach creates a dependency between the domain assembly and the ACL, which is not permissible. Therefore, should DTO objects be included in the domain assembly solely for convenience.
Somewhere a string is getting converted to a domain model which means the domain assembly knows about strings and other primitive types so why not have DTOs, then I can do the following in the application layer.
UpdateShoppingListCommand.TryCreate(updateShoppinglistRequestDto)

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

No branches or pull requests

2 participants