Gopal
Gopal

Reputation: 265

How to handle Updated/modified by on Entities while using Domain Driven Design

We are currently attempting to apply the principles of Domain Driven Design in our .NET based application (ASP.NET, WCF, Castle Windsor, NHibernate stack)

The question is at the table level, we have updated by (string), updated on (datetime) for Order. When the order is approved, we need to get the updated by, updated on reflect the approver name and the date/time when he approved.

Do you guys do something as below in the Application Layer? Please advise
order = orderRepository.Find(orderId) order.businessLogicCall1()
order.businessLogicCall2()
order.updatedBy(userName)
orderRepository.Save(order)

Where the order.updatedBy() call also updates the internal field updatedOn for date/time when the update was performed. This gets posted onto the table by Nhibernate

Upvotes: 1

Views: 131

Answers (1)

Yves Reynhout
Yves Reynhout

Reputation: 2990

Why not order.Approve(anApprover, approvalDate) where anApprover is the one that approved it? How that gets represented in the DB is up to you. Orthogonal to that are the persistence mechanisms that save who performed the action (could be an enduser) along with each affected entity. This kind of storage has less business meaning.

Upvotes: 1

Related Questions