Skip to content

Instantly share code, notes, and snippets.

@plioi
Last active January 27, 2016 14:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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