public ActionResult Contact() { ViewBag.Message = "Your contact page."; var temp = new FeedbackForm(); return View(temp); }
public ActionResult Contact(FeedbackForm model) { var rez = new EmailBodyGenerator(model); var text = rez.GenerateEmailBody(); var tempForm = new FeedbackForm(); if (Session["Captcha"].ToString() != model.Captcha ) { ModelState.AddModelError("Captcha", Translations.CaptchaValidation); return View(); } try { EmailSender.SendEmail(AppSettings.FromEmailAddress, AppSettings.ToEmailAddress, Translations.Contact_Form_Message_Field, text); ViewBag.SendContactSuccess = Translations.SubmitSuccess; ModelState.Clear(); } catch (Exception) { ViewBag.SmtpError = Translations.SmtpError; } if (Session["Captcha"] == null) { return RedirectToAction("Contact", "Home"); } return View(tempForm); }
public EmailBodyGenerator(FeedbackForm model) { _userName = model.Name; _emailTo = model.Email; _userMessage = model.Message; }