35 lines
938 B
C#
35 lines
938 B
C#
using System.Web.Mvc;
|
|
using Hangfire;
|
|
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
|
|
{
|
|
BackgroundJob.Enqueue<EmailNotificationService>(
|
|
e => e.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();
|
|
}
|
|
}
|
|
} |