Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }