public static ContactPageViewModel Populate(UnitOfWork work = null) { if (work == null) work = new UnitOfWork(); ContactPageViewModel model = new ContactPageViewModel(); if (WebSecurity.IsAuthenticated) { var currentUser = work.EntityContext.user.Find(WebSecurity.CurrentUserId); model.SenderEmail = currentUser.email; model.SenderName = currentUser.first_name + " " +currentUser.last_name; } return model; }
public static ContactPageViewModel Populate(UnitOfWork work = null) { if (work == null) { work = new UnitOfWork(); } ContactPageViewModel model = new ContactPageViewModel(); if (WebSecurity.IsAuthenticated) { var currentUser = work.EntityContext.user.Find(WebSecurity.CurrentUserId); model.SenderEmail = currentUser.email; model.SenderName = currentUser.first_name + " " + currentUser.last_name; } return(model); }
public ActionResult Contact(ContactPageViewModel model) { if (bool.Parse(JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.DevPasswordEnabled))) { if (model.DevPassword == null || !model.DevPassword.Equals(JPPConstants.devPassword)) ModelState.AddModelError("", "The Dev password is incorrect"); } if (ModelState.IsValid) { Email.Send(JPPConstants.SiteSettings.AdminEmail, model.SenderName, model.SenderMessage); ViewBag.DevPassword = bool.Parse(JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.DevPasswordEnabled)); ViewBag.Success = true; return View(); } ViewBag.DevPassword = bool.Parse(JPPConstants.SiteSettings.GetValue(JPPConstants.SiteSettings.DevPasswordEnabled)); ViewBag.Success = false; return View(model); }