Hi Brian,
First off thanks for buying the book and taking time to post this question.
The reason I inject the unit of work in via the repository is because an atomic action may span more than one repository. If you take a look on page 245 you can see that there is a call to the unit of works commit method within the AddMember method. The business transaction commits when the service says so.. consider the following senario...
Code:
var customer = customerRepository.FindBy(cusomerId);
var order = new Order();
// populate the order...
order.Customer = customer;
customer.YearlyOrderSpendAdd(order.Total);
// The customer has now been modified and the order needs to be added..
customerRepository.Save(customer);
orderRepository.Add(order);
// we only want to call commit now because we don't want an error to occur
// and the customer be saved but not the order added.
// The commit ensures that what has been addded/changed/removed it committed
// in a transaction as an atomic event i.e. all or nothing
uow.Commit();
I hope that make sense? If not please let me know and I can expand.
Cheers
Scott
p.s. would be great if you could adda review to Amazon and give me some feedback when you have finished the book :0) cheers!