Esempio n. 1
0
        public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            base.OnActionExecuting(actionContext);

            var instance = CommerceInstance.Current;
            if (instance == null)
                throw new InvalidOperationException(typeof(TransactionalAttribute).Name + " can only be applied to an action within commerce instance context.");

            _transaction = instance.Database.BeginTransaction();
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            var commerceContext = EngineContext.Current.Resolve<CommerceInstanceContext>();
            var currentInstance = commerceContext.CurrentInstance;
            if (currentInstance == null)
                throw new InvalidOperationException(typeof(TransactionalAttribute).Name + " can only be applied to an action within commerce instance context.");

            _transaction = currentInstance.Database.BeginTransaction();
        }
        public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            base.OnActionExecuting(actionContext);

            var instance = CommerceInstance.Current;

            if (instance == null)
            {
                throw new InvalidOperationException(typeof(TransactionalAttribute).Name + " can only be applied to an action within commerce instance context.");
            }

            _transaction = instance.Database.BeginTransaction();
        }
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            try
            {
                if (actionExecutedContext.Exception == null && !_transaction.IsCommitted)
                {
                    _transaction.Commit();
                }
            }
            finally
            {
                // reset fields to null in case the filter instance is cached by asp.net mvc
                _transaction.Dispose();
                _transaction = null;
            }

            base.OnActionExecuted(actionExecutedContext);
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            try
            {
                if (filterContext.Exception == null && !_transaction.IsCommitted)
                {
                    _transaction.Commit();
                }
            }
            finally
            {
                // reset fields to null in case the filter instance is cached by asp.net mvc
                _transaction.Dispose();
                _transaction = null;
            }

            base.OnActionExecuted(filterContext);
        }