.net - Is It Okay for an Application Layer with a multi-step process to not use the domain layer -


i working on n-layered .net application following layers:

  • presentation
  • application
  • domain
  • infrastructure (contains persistence , common utility functions email)

at point in application, request approved. once approved, there 4 steps must performed follows:

  1. assign product tag code issued product in request.
  2. update request status “being processed” “order completed”
  3. send email requester stating product ready pickup
  4. send email requester’s manager informing them of employee has been given , copy of request approved product

the above steps must part of atomic operation meaning must done or action cancelled. thinking of having application layer directing request repository , persistence layer carry out tasks follows:

  1. application layer requests request repository perform steps 1 , 2 unit of work transaction
  2. application layer requests infrastructure layer carry out steps 3 , 4.

i'm not sure if application layer supposed this. think because first 2 actions require contacting repository have avoided doing in domain layer. last 2 steps involve infrastructure layer domain layer may talk via dependency injected instance. following logic, application layer not asking domain layer anything. typically how multi-step process when have application layer? or did miss here?

i aware of framework called windows workflow i'm not sure if in case multi-step process not involve human interaction along processing steps things waiting few days. don't want make application overly complex if don't have to.

thanks in advance.

steps 1 , 2 in question sound domain logic me. no, not okay. these 2 steps should carried out in domain. can following:

  1. in application service, load relevant aggregate (probably request).

  2. either invoke operation step 1 , 2 on request, or (if operation not belong request) invoke domain service performs these 2 steps.

  3. once domain operation completed, application service can save modified request db.

  4. if above steps successful, can send emails. should have kind of retry mechanism in place, email gets sent eventually, if there temporary problem.

if changes in step 2 modify more 1 aggregate, process becomes more complex. sagas mentioned in comments 1 solution problem. still, individual changes domain operations, model them accordingly.

as suggested plalx in comment, sending of emails can offloaded domain event consumer if have eventing infrastructure in place. solves retry mechanism free.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -