コード例 #1
0
ファイル: Includes.cs プロジェクト: Vin2454/samples
        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);
        }
コード例 #2
0
ファイル: Includes.cs プロジェクト: Vin2454/samples
        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();
        }
コード例 #3
0
ファイル: Includes.cs プロジェクト: Vin2454/samples
        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();
        }