예제 #1
0
        public void FormController_Save_CallsFormServiceSaveFormDataWithPassedObjects()
        {
            var stubWebpage = new StubWebpage();

            A.CallTo(() => _formPostingHandler.GetWebpage(123)).Returns(stubWebpage);

            ActionResult result = _formController.Save(123);

            A.CallTo(() => _formPostingHandler.SaveFormData(stubWebpage, _formController.Request)).MustHaveHappened();
        }
예제 #2
0
        public ActionResult Save(int id)
        {
            var webpage = _formPostingHandler.GetWebpage(id);

            if (webpage?.IsDeleted != false)
            {
                return(new EmptyResult());
            }
            var saveFormData = _formPostingHandler.SaveFormData(webpage, Request);

            TempData["form-submitted"]         = true;
            TempData["form-submitted-message"] = saveFormData;
            // if any errors add form data to be renderered, otherwise form should be empty
            TempData["form-data"] = saveFormData.Any() ? Request.Form : null;

            var redirectUrl = Referrer.ToString();

            if (!string.IsNullOrEmpty(webpage.FormRedirectUrl) && !saveFormData.Any())
            {
                redirectUrl = webpage.FormRedirectUrl;
            }
            return(Redirect(redirectUrl));
        }