asp.net mvc - CQRS where to put domain / business logic -
i developing framework mvc application. part of framework, have created dummy application. following onion architecture , solid principle cqrs. first project mvc , cqrs. following chain of responsibility in cqrs.
at present not sure part should keep business logic.
example. have command of debit account bank account. have created command debitaccount , handler idebitaccounthandler. idebitaccounthandler implemented in infrastructure layer required dependencies debitaccounthandler.
here have core logic of checking balance before debiting account. want implement in core not change infrastructure.
now should implement logic , load required dependencies. commands interfaces without method body, contain on method of handle/execute.
i feel newbie question , arising due limited understanding of patterns.
each command represents use case. command handler doesn't contain logic; takes care of infrastructural concerns, , delegates domain.
you want logic in domain model: aggregates, entities, value objects, services... in example, logic encapsulated account
aggregate.
public class account { private balance _balance; public void debit(amount amount) { if (_balance.issufficient()) // debit.. } }
Comments
Post a Comment