Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    Could you explain why Save, Submit and Approve command payloads all need to contain the full SalesOrder? Usually, validating a command is rarely the same as validating an entity, as a very limited number of commands should contain the full entity. An alternative is to let the domain layer validate the entity. Commented Jun 27, 2023 at 7:46
  • @guillaume31 For the Approve, yes, it doesn't necessarily need the full details. For Save and Submit it needs the full details since in our scenario, these actions are initiated right after the user encode/edit the form (not yet persisted in db). So a user can edit a form and click Save if it's not yet final or Submit if what they edited is final. Both of these actions would still have to persist the updated record in database and have a high probability of having same validation. Commented Jun 27, 2023 at 10:22
  • I would agree that the domain layer is the best place for this but if we go this route, this would mean we'll maintain yet another set of POCOs aside from auto-generated entities of EF and command. There's a lot of mapping again. A rich domain layer would really solve most of these but we're looking for alternatives as much as possible to limit overengineering some of our simple applications. Commented Jun 27, 2023 at 10:29
  • 1
    It is unclear to me why you don't just add a reusable component that both the Save and Submit command handlers depend on to perform the same validation. Did you miss this as an option or is there a reason you're not taking this route? Commented Jul 27, 2023 at 0:20