public override void OnActionExecuted(ActionExecutedContext actionExecutedContext) { AbstractApiController controller = (AbstractApiController)actionExecutedContext.Controller; if (actionExecutedContext.Exception == null) { try { controller.TransactionCooordinator.CommitTransaction(); } catch (DbUpdateConcurrencyException) { throw; } catch (Exception) { throw; } } else { try { controller.TransactionCooordinator.RollbackTransaction(); } catch (Exception) { throw; } } base.OnActionExecuted(actionExecutedContext); }
public override void OnActionExecuting(ActionExecutingContext actionContext) { if (!(actionContext.Controller is AbstractApiController)) { throw new Exception("UnitOfWorkActionFilter can only be applied to controllers that inherit from AbstractApiController"); } AbstractApiController controller = (AbstractApiController)actionContext.Controller; controller.TransactionCooordinator.BeginTransaction(); }
public override void OnActionExecuting(ActionExecutingContext actionContext) { if (!(actionContext.Controller is AbstractApiController)) { throw new Exception("ReadOnlyFilter can only be applied to controllers that inherit from AbstractApiController"); } AbstractApiController controller = (AbstractApiController)actionContext.Controller; controller.TransactionCooordinator.DisableChangeTracking(); }