protected virtual void Commit(ControllerContextWrapper controllerContextWrapper)
        {
            if (controllerContextWrapper.ControllerContext.IsChildAction)
            {
                return;
            }

            if (controllerContextWrapper.Exception != null &&
                !controllerContextWrapper.ExceptionHandled)
            {
                GetSessionManager().Rollback();
                return;
            }

            var controller = controllerContextWrapper.ControllerContext.Controller;

            if (UseSessionController)
            {
                controller = controllerContextWrapper.ControllerContext.Controller as SessionController;

                if (controller == null)
                {
                    return;
                }
            }

            if (controller.ViewData.ModelState.IsValid)
            {
                GetSessionManager().Commit();
            }
            else
            {
                GetSessionManager().Rollback();
            }
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            if (CommitOn != CommitOnType.OnResultExecuted)
            {
                return;
            }

            var controllerContextWapper = new ControllerContextWrapper
                {
                    ControllerContext = filterContext,
                    Exception = filterContext.Exception,
                    ExceptionHandled = filterContext.ExceptionHandled
                };

            Commit(controllerContextWapper);
        }