Beispiel #1
0
        internal async Task AddContactFormToDBAsync(InfoContactVM infoContactVM)
        {
            var x = infoContactVM.Sitekey;
            await foodObjContext.ContactForm.AddAsync(new ContactForm {
                Email    = infoContactVM.Email,
                Name     = infoContactVM.Name,
                Question = infoContactVM.Description
            });

            await foodObjContext.SaveChangesAsync();
        }
Beispiel #2
0
        public async Task <IActionResult> Contact(InfoContactVM infoContactVM)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Contact)));
            }
            if (!InfoService.ReCaptchaPassed(
                    Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
                    _configuration.GetSection("GoogleReCaptcha:secret").Value
                    ))
            {
                ModelState.AddModelError(nameof(infoContactVM.ReCAPTCHA), "You failed the CAPTCHA, stupid robot.");
                return(View(infoContactVM));
            }
            await infoService.AddContactFormToDBAsync(infoContactVM);

            return(RedirectToAction(nameof(Contact)));
        }