Skip to content

Instantly share code, notes, and snippets.

@plioi
Last active January 27, 2016 14:26
Show Gist options
  • Select an option

  • Save plioi/07101c973abf2676703b to your computer and use it in GitHub Desktop.

Select an option

Save plioi/07101c973abf2676703b to your computer and use it in GitHub Desktop.
public class UnitOfWork : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var database = DependencyResolver.Current.GetService<ContactsContext>();
database.BeginTransaction();
}
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
var database = DependencyResolver.Current.GetService<ContactsContext>();
database.CloseTransaction(filterContext.Exception);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment