public ActionResult SubmitContactUsForm(ContactUs model) { if (ModelState.IsValid) { string encodedResponse = Request.Form["g-Recaptcha-Response"]; var response = ReCaptcha.Validate(encodedResponse, SensativeInformation.ReCaptchaKeys.ReCaptchaSecretKey); bool isCaptchaValid = response.ToLower() == "true" ? true : false; if (!isCaptchaValid) { ModelState.AddModelError("", "Please verify you are not a robot"); return(CurrentUmbracoPage()); } ContactUsEmailModel emailModel = new ContactUsEmailModel(); emailModel.Info = model; emailModel.BaseUri = UrlHelpers.GetBaseUrl(); ViewData.Model = emailModel; var html = RazorHelpers.RenderRazorViewToString("~/Views/Emails/ContactUsEmail.cshtml", ControllerContext, ViewData, TempData); var emailService = new EmailService.EmailHelpers(); emailService.SendEmail("*****@*****.**", "Query from contact form", html); TempData["Success"] = "That is winging its way to us now. We will be in contact as soon as we can."; return(RedirectToCurrentUmbracoPage()); } return(CurrentUmbracoPage()); }
public static void MembershipRenewalReminders() { HttpContextWrapper c = new HttpContextWrapper(HttpContext.Current); RouteData routeData = new RouteData(); routeData.Values.Add("controller", typeof(MembershipSurfaceController).Name.ToLower().Replace("controller", "")); ControllerContext controllerContext = new ControllerContext(new RequestContext(c, routeData), new MembershipSurfaceController()); ViewDataDictionary viewData = new ViewDataDictionary(); TempDataDictionary tempData = new TempDataDictionary(); DataManager dm = new DataManager(); var members = dm.GetCurrentMemberships(); //send reminder a week before var model = new MembershipRenewal(); model.BaseUri = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/'); ViewData.Model = model; var html = RazorHelpers.RenderRazorViewToString("~/Views/Reports/VehicleRegistrationReport.cshtml", ControllerContext, ViewData, TempData); var stream = pdfService.GenertatePdfFromHtml(html); foreach (var m in members.Where(n => n.EndDate.Date >= DateTime.UtcNow.Date.AddDays(-100)).ToList()) { if(m.IsSubscription) html = RazorHelpers.RenderRazorViewToString("") } foreach (var m in members.Where(n => n.EndDate.Date >= DateTime.UtcNow.Date).ToList()) { Debug.WriteLine($"Membership a week from renewal. Member id: {m.Member} End date: {m.EndDate} MembershipId: {m.MembershipId}"); } }