コード例 #1
0
ファイル: LifecycleHandler.cs プロジェクト: ariugwu/sharpbox
        public void ProcessRequest(WebContext <T> webContext, ISharpboxController <T> controller)
        {
            try
            {
                this.HandleRequest(webContext, controller);
                this.PopulateLifeCycleTrail(webContext);
            }
            catch (Exception ex)
            {
                if (webContext.WebResponse == null)
                {
                    webContext.WebResponse = new WebResponse <T>()
                    {
                        ModelErrors = new Dictionary <string, Stack <ModelError> >()
                    };
                }

                this.AddModelStateError(webContext, controller, "ExecutionError", new ModelError(ex, ex.Message));
            }

            if (this._successor != null && controller.IsModelStateValid())
            {
                this._successor.ProcessRequest(webContext, controller);
            }
        }
コード例 #2
0
        public override void HandleRequest(WebContext <T> webContext, ISharpboxController <T> controller)
        {
            if (!controller.IsModelStateValid())
            {
                controller.MigrateModelErrorsToWebContext();
                return;
            }

            this.Validator = controller.LoadValidatorByUiAction(webContext.WebRequest.UiAction);

            if (!this.Validate(webContext.WebRequest))
            {
                webContext.WebResponse.Instance = webContext.WebRequest.Instance;

                foreach (var e in this.ValidationResult.Errors)
                {
                    AddModelStateError(webContext, controller, e.PropertyName, new ModelError(e.ErrorMessage));
                }
            }
        }