public async Task <IActionResult> PrayerRequest(PrayerRequestViewModel requestModel)
        {
            requestModel.Title = "Submit a Prayer Request";
            SiteVerifyResult reCaptchaVerifyResult = null;

            if (requestModel == null)
            {
                ModelState.AddModelError("", "requestModel was Null");
            }
            else if (requestModel.ReCaptchaResponse == null)
            {
                ModelState.AddModelError("", "requestModel.ReCaptchaResponse was Null");
            }
            else
            {
                try
                {
                    reCaptchaVerifyResult = await _ReCaptchaService.VerifyReCaptchaAsync(requestModel.ReCaptchaResponse);
                }
                catch (Exception)
                {
                }
            }


            if (reCaptchaVerifyResult != null)
            {
                if (reCaptchaVerifyResult.ResultStatus != ReCaptcha.enums.ResultStatus.Ok || reCaptchaVerifyResult.IsVerified == false)
                {
                    var resultCd = reCaptchaVerifyResult.ResultStatus switch
                    {
                        ResultStatus.Ok => "Ok",
                        ResultStatus.BadRequest => "Bad Request",
                        ResultStatus.Conflict => "Conflict",
                        ResultStatus.Error => "Error",
                        ResultStatus.NotFound => "Not Found",
                        ResultStatus.Unauthorized => "Unauthorized",
                        _ => "Unknown"
                    };

                    ModelState.AddModelError(string.Empty, resultCd + " " + reCaptchaVerifyResult.ResultStatusMessages[0].Message);
                }
            }

            if (!ModelState.IsValid)
            {
                return(View(requestModel));
            }

            await _RequestsService.InsertAPrayerRequestAsync(requestModel.PrayerRequest);

            var msg = "Thank you for your prayer request.  Your request will be reviewed by a knight and included in our group prayer at our council meeting. ";

            msg += "If your request was marked urgent, your request may be forwarded to brother knights to include with their individual prayer intentions.";

            var postSavePopup = new PopupModel()
            {
                Title   = "Prayer Request Submitted",
                Body    = msg,
                Buttons = new PopupButtonModel[]
                {
                    new PopupButtonModel(Core.Enums.ButtonType.Close)
                }
            };

            var _popupJson = JsonSerializer.Serialize(postSavePopup);

            return(RedirectToAction("Index", new RouteValueDictionary(
                                        new { controller = "Home", action = "Index", popupJson = _popupJson })));
        }
    }
Пример #2
0
        public async Task <IActionResult> ContactUs(ContactUsViewModel requestModel)
        {
            requestModel.Title = "Contact Us";
            SiteVerifyResult reCaptchaVerifyResult = null;

            if (requestModel == null)
            {
                ModelState.AddModelError("", "requestModel was Null");
            }
            else if (requestModel.ReCaptchaResponse == null)
            {
                ModelState.AddModelError("", "requestModel.ReCaptchaResponse was Null");
            }
            else
            {
                try
                {
                    reCaptchaVerifyResult = await _ReCaptchaService.VerifyReCaptchaAsync(requestModel.ReCaptchaResponse);
                }
                catch (Exception)
                {
                }
            }


            if (reCaptchaVerifyResult != null)
            {
                if (reCaptchaVerifyResult.ResultStatus != ReCaptcha.enums.ResultStatus.Ok || reCaptchaVerifyResult.IsVerified == false)
                {
                    var resultCd = reCaptchaVerifyResult.ResultStatus switch
                    {
                        ResultStatus.Ok => "Ok",
                        ResultStatus.BadRequest => "Bad Request",
                        ResultStatus.Conflict => "Conflict",
                        ResultStatus.Error => "Error",
                        ResultStatus.NotFound => "Not Found",
                        ResultStatus.Unauthorized => "Unauthorized",
                        _ => "Unknown"
                    };

                    ModelState.AddModelError(string.Empty, resultCd + " " + reCaptchaVerifyResult.ResultStatusMessages[0].Message);
                }
            }

            if (!ModelState.IsValid)
            {
                return(View(requestModel));
            }

            await _RequestsService.InsertAContactUsMessageAsync(requestModel.ContactUsMessage);

            var msg = "Thank you for your contact request.  Your request will be reviewed by a knight and addressed as soon as possible. ";

            var postSavePopup = new PopupModel()
            {
                Title   = "Contact Request Submitted",
                Body    = msg,
                Buttons = new PopupButtonModel[]
                {
                    new PopupButtonModel(Core.Enums.ButtonType.Close)
                }
            };

            var _popupJson = JsonSerializer.Serialize(postSavePopup);

            return(RedirectToAction("Index", new RouteValueDictionary(
                                        new { controller = "Home", action = "Index", popupJson = _popupJson })));
        }