Hi,
I have a DAL to CRUD product data.
For example:
Order someOrder = new Order();
someOrder.Description = "Test";
someOrder.Save();
someOrder.Remove();
I need to design the DAL so that only users who have a lock on an Order type object can carry out CRUD operations.
My idea is to pass the session to the CRUD methods. Once I pass the session, the method will check whether that user has a lock on that specific object, and if yes, it will carry proceed with executing that method.
For example:
someOrder.Save(sessionThatContainsLockInformation);
// Pseudo-code
public void Save(Session session)
{
1. Get user GUID from the session.
2. Get lock details from the session.
3. Check that the provided user has a lock.
4. On success, proceed with saving the order.
}
I'm concerned with the fact that I'm using Sessions in the data access layer. My intuition tells me that I shouldn't be doing this. My goal is to write as little code as possible to promote the re-usability of code, but I seem to be stuck with the same ideas.
Can somebody please advise me on whether this is a sensible approach, or whether it has some fundamental disadvantages or maintenance overheads?
Any alternative solutions are welcome. I'm not interested in the code, just some ideas please.
Thank you