public async Task <IActionResult> SubmitContactFormAsync() { if (!IoMaster.VerifyRecaptcha(Request.Form["g-recaptcha-response"], Request.Headers["X-forwarded-for"], "contact")) { return(CustomError("reCAPTCHA validation failed")); } string name = Request.Form["name"]; string email = Request.Form["email"]; string subject = Request.Form["subject"]; string message = Request.Form["message"]; EmailSender mailsend = new EmailSender(); await mailsend.SendEmailAsync(new ContactFormEmail { Message = message, Subject = subject, ReplyTo = new MailAddress(email, name), UserIP = Request.Headers["X-forwarded-for"], UserCountryCode = Request.Headers["cf-ipcountry"] }); TempData["SuccessAlert"] = "Din melding har blitt sendt"; return(Redirect("/Home/Contact")); }
public IActionResult CreateCustom() { //Verify Google reCAPTCHA if (!IoMaster.VerifyRecaptcha(Request.Form["g-recaptcha-response"], Request.Headers["X-forwarded-for"], "createcustom")) { return(CustomError("reCAPTCHA validation failed")); } //Check that form data is provided if (string.IsNullOrEmpty(Request.Form["endtext"]) || string.IsNullOrEmpty(Request.Form["cdtext"]) || string.IsNullOrEmpty(Request.Form["background"]) || string.IsNullOrEmpty(Request.Form["time"]) || string.IsNullOrEmpty(Request.Form["recursion"]) || string.IsNullOrEmpty(Request.Form["timezone"])) { return(View("CustomError", new CountdownErrorViewModel { Message = "Missing one or more required parameters." })); } //Retrieve form data string cdtext = Request.Form["cdtext"]; string endtext = Request.Form["endtext"]; string type = (string)Request.Form["recursion"] switch { "yearly" => "custom-reccurring", "weekly" => "weekly", "monthly" => "monthly", _ => "custom" }; bool uselocal = (string)Request.Form["timezone"] switch { "local" => true, _ => false }; string background = Request.Form["background"]; DateTime date = DateTime.Parse(Request.Form["time"], null, DateTimeStyles.RoundtripKind); CountdownBackground bg = CountdownBackground.Backgrounds[background]; string countdownid; try { countdownid = CountdownSqlAgent.CreateCustomCountdown(User.FindFirstValue(ClaimTypes.NameIdentifier), type, date, bg.Path, cdtext, endtext, bg.Html, bg.Css, bg.UseCCC, uselocal); } catch (BadSqlException) { //';', '\'', '*', '/', '-', '_', '"' return(CustomError("Ulovlig input. Tegnene ;, ', *, /, -, _ og \" kan ikke brukes.")); } return(Redirect($"/Countdown/Custom/{countdownid}")); }