using System.Web.Mvc; using log4net; using LeafWeb.WebCms.Models; using LeafWeb.WebCms.Services; namespace LeafWeb.WebCms.Controllers { public class ContactController : BaseController { public ActionResult Index() { var viewModel = new ContactForm(); return PartialView(viewModel); } [HttpPost] public ActionResult Submit(ContactForm viewModel) { if (ModelState.IsValid) // HttpParamMatch indicates it's backing out from Confirm { // convert viewModel into Model new EmailNotificationService().SendContactEmail(viewModel); var logger = LogManager.GetLogger(GetType()); logger.Info($"Contact: Name:{viewModel.Name} Added, Email:{viewModel.Email}, Message:{viewModel.Message}"); SetStatusMessage("Your message has been sent!", StatusType.Success); return RedirectToCurrentUmbracoPage(); } return CurrentUmbracoPage(); } } }