I've been playing around with my architecture a bit the last few days, trying to make things a little more streamlined, and I wanted to get some outside input on it before I sealed everything up again.

The big change is how I handle my unit of work. Previously, my abstract base controller took an IUnitOfWorkFactory as a constructor parameter, and exposed it as a property. But not all my derived controllers made use of it.

So what I did was removed it from the constructor and added the following to it instead:

Code Csharp:
 
// in case of special needs
protected T Resolve<T>()
{
return DependencyResolver.Current.GetService<T>();
}
 
protected IUnitOfWorkFactoy UnitOfWorkFactory
{
get { return Resolve<IUnitOfWorkFactory>(); }
}

Now, the factory is available, if and when, I need it, like so:

Code Csharp:
public ActionResult Edit(FooEditModel model)
{
 
Foo f = fooRepository.SelectById(model.Id);
// update f from model omitted
 
// wrap next call in a transaction
using (var uow = UnitOfWorkFactory.Create())
fooRepository.Update(f);
 
}

Thoughts or opinions on this? Is there a better, or different way, to do it that I might not have considered?