Beispiel #1
0
        public ActionResult MobileSubmit(ContactFormViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (viewModel.Save(viewModel))
                    {
                        return(RedirectToAction("Thanks"));
                    }
                }
                return(View("CreateContact"));
            }
            catch (Exception ex)
            {
#if DEBUG
                ViewData["Exception"] = "Exception: " + ex.Message + " ";
                if (ex.InnerException != null)
                {
                    string innerAddOn = " " + ex.InnerException;
                    ViewData["Exception"] += innerAddOn;
                }
#endif
                return(View("CreateContact"));
            }
        }
Beispiel #2
0
        public ActionResult Submit(ContactFormViewModel viewModel, bool captchaValid, string captchaErrorMessage)
        {
            try
            {
                //string privateKey = WebConfigurationManager.AppSettings["ReCaptchaPrivateKey"];
                //if (ReCaptcha.Validate(privateKey) && ModelState.IsValid)

                if (!captchaValid)
                {
                    if (!HttpContext.Request.Browser.IsMobileDevice)
                    {
                        ModelState.AddModelError("captcha", captchaErrorMessage);
                    }
                }

                if (ModelState.IsValid)
                {
                    if (viewModel.Save(viewModel))
                    {
                        return(RedirectToAction("Thanks"));
                    }
                }
                return(View("CreateContact"));
            }
            catch (Exception ex)
            {
#if DEBUG
                ViewData["Exception"] = "Exception: " + ex.Message + " ";
                if (ex.InnerException != null)
                {
                    string innerAddOn = " " + ex.InnerException;
                    ViewData["Exception"] += innerAddOn;
                }
#endif
                return(View("CreateContact"));
            }
        }