public ActionResult Send(string name = null, string phone = null, string email = null, int contact_type = 0, string message = null) { ContactInquiry inq = new ContactInquiry(); try { inq = new ContactInquiry { name = name, phone = phone, email = email, contact_type = contact_type, message = message, dateAdded = DateTime.UtcNow, followedUp = 0 }; bool recaptchavalid = ReCaptcha.ValidateCaptcha(System.Web.HttpContext.Current, Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"]); if (!recaptchavalid) throw new Exception("Captcha Incorrect!"); UDF.Sanitize(inq, new string[] { "phone", "followedUp" }); inq.Save(); TempData["error"] = "Thank you for your inquiry, someone will contact you soon to follow up with your request."; return RedirectToAction("Index", "Contact"); } catch (Exception e) { TempData["inquiry"] = inq; TempData["error"] = e.Message; return RedirectToAction("Index", "Contact"); } }
public ActionResult Send(string name = null, string phone = null, string email = null, int contact_type = 0, string message = null) { string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"]; ContactInquiry inq = new ContactInquiry(); try { inq = new ContactInquiry { name = name, phone = phone, email = email, contact_type = contact_type, message = message, dateAdded = DateTime.Now, followedUp = 0 }; bool recaptchavalid = ReCaptcha.ValidateCaptcha(Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"], remoteip); if (!recaptchavalid) throw new Exception("Captcha Incorrect!"); UDF.Sanitize(inq, new string[] { "phone", "followedUp" }); inq.Save(); TempData["error"] = "Thank you for your inquiry, someone will contact you soon to follow up with your request."; return RedirectToAction("Index", "Contact"); } catch (Exception e) { TempData["inquiry"] = inq; TempData["error"] = e.Message; return RedirectToAction("Index", "Contact"); } }
public ActionResult SendAJAX(string name = null, string phone = null, string email = null, string to = null, string message = null, string recaptcha_challenge_field = null, string recaptcha_response_field = null) { ContactInquiry inq = new ContactInquiry(); try { inq = new ContactInquiry { name = name, phone = phone, email = email, contact_type = 0, message = message, dateAdded = DateTime.UtcNow, followedUp = 0 }; bool recaptchavalid = ReCaptcha.ValidateCaptcha(System.Web.HttpContext.Current, recaptcha_challenge_field, recaptcha_response_field); if (!recaptchavalid) throw new Exception("Captcha Incorrect!"); UDF.Sanitize(inq, new string[] { "phone", "contact_type", "followedUp" }); inq.Save(true, to); TempData["error"] = "Thank you for your contact inquiry. Someone will respond to your request in a timely matter."; return RedirectToAction("Index","Locations"); } catch (Exception e) { TempData["error"] = "Sorry, an error has occurred while processing your request." + e.Message; return RedirectToAction("Index", "Locations"); } }