Example #1
0
        protected override void Invoke(object parameter)
        {
            if (AssociatedObject == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(this.Url))
            {
                throw new ControllerActionException(ACTIONURL_NOT_VALID, ResponseStatus.UrlInvalid);
            }

            var _url        = Url;
            var _parameters = (DependencyParameterCollection)GetValue(ParametersProperty);
            var _handler    = ResolveHandler();

            var _request = new ControllerActionRequest(_url, _parameters, this.SiteArea, _handler, this.AssociatedObject);

            ControllerService.Execute(_request, (s) =>
            {
                if (s != ResponseStatus.Success && s != ResponseStatus.Cancelled)
                {
                    throw new ControllerActionException(string.Format(ACTION_COULDNOT_EXECUTE, _url), s, _request);
                }
            });
        }
        protected override void Invoke(object parameter)
        {
            if (this.AssociatedObject == null)
            {
                return;
            }

            var _actionNode = this.ControllerActionNode;

            if (_actionNode == null && !string.IsNullOrEmpty(this.ControllerActionNodeKey))
            {
                if (!SiteMapService.IsSiteMapLoaded)
                {
                    SiteMapService.LoadSiteMap((s) => this.Invoke(null));
                    return;
                }
                _actionNode = SiteMapService.ResolveSiteMapNode(ControllerActionNodeKey) as ControllerActionNode;
            }

            if (_actionNode == null)
            {
                throw new ControllerActionException(NODE_NOT_FOUND, ResponseStatus.HandlerNotFound);
            }

            var _request = new ControllerActionRequest(_actionNode.Url, _actionNode.UrlParameters, _actionNode.SiteArea, base.ResolveHandler(), this.AssociatedObject);

            ControllerService.Execute(_request, (s) =>
            {
                if (s != ResponseStatus.Success && s != ResponseStatus.Cancelled)
                {
                    throw new ControllerActionException(string.Format(ACTION_COULDNOT_EXECUTE, _actionNode.Url), s, _request);
                }
            });
        }