0

This is my VS solution:

VS Solution

And this is the architecture:

Architecture

I have few questions:

1) Where should i start a transaction and commit? Service layer or Presentation layer ? 2) Where should i acess Data layer ? From Service layer or from Model/Core/Domain layer ? 3) Where should i acess "ProductDAO" for update product quantity ?

Rieth
  • 305
  • 1
  • 4
  • 13

1 Answers1

2

1) I would start it on the service layer. Presentation doesn't really need to know about transactions, and the Service layer is the one doing multiple operations that want to be atomic

2) For acccessing the DAL thats not as clear. I would go for service layer as it is "the glue" between your other classes. But it could make sense to make your domain models know about it.

3) Commit should be in the same place as the transaction is initiated otherwise you could end up with complex code and scenarios where a transaction doens't get either commited or rolled back.

Juan
  • 3,675
  • 20
  • 34
  • 1) But if i use 2 services, in wich of them i start the transactions ? For example: Client1 use Service1 and Service2, if i start transaction at Client1(presentation layer) i can commit only if Service1 and Service2 worked... – Rieth May 11 '15 at 16:25
  • Then add a controller taht inits the transaction and call the two different services :) – Juan May 11 '15 at 16:32
  • In other words, u said that i must inits the transaction at presentation layer... and if i have two applications that uses the services ? i will need manage transactions for both... – Rieth May 13 '15 at 00:12
  • Not really. By a controller i didnt meant a view controller but a service controller. It can be in the same namespace and component that other services. For exampke if services involved are customer and order service you could have a TransactionService that consumes both and is in charge of the transaction. You could also use the UnitOfWork pattern and let the Uo handle the transaction – Juan May 13 '15 at 08:09