I have been working on a new ASP.NET MVC application and trying my best to implement the Service Layer/Repository/UOW patter using EF4 and POCO classes.
Help me see if I am understanding this correctly.
Lets say for the sake of keeping this simple, that a client is requesting a view of a Customer.
1) Client requests a view from the CustomerController.
2) The CustomerController creates a new UOW and a new CustomerService passing in the UOW.
3) The CustomerService creates a new Repository(Of Customer) and passes in the UOW it received from the CustomerService. This is the layer where you would say maybe something like "Are you allowed to view this customer?"
4) The CustomerRepository handles getting the POCO classes from the EF4.
5) The CustomerRepository hands the POCO classes back to the CustomerService, which then hands them back to the CustomerController.
6) The CustomerController uses the POCO classes to fill the CustomerViewModel and then hands the CustomerViewModel off to the CustomerView.
I am still a little confused on why/where to use AutoMapper???
Any advice on this would be greatly appreciated.