public async Task <IActionResult> SendEmail(ContactsInputModel inputModel) { try { await this.emailSender.SendEmailAsync(inputModel.Email, inputModel.Name, "*****@*****.**", inputModel.Subject, inputModel.Message); } catch (ArgumentException ex) { return(this.RedirectToAction("Index", new { message = ex.Message })); } return(this.RedirectToAction("Index", new { message = "Вашето съобщение беше изпратено успешно!" })); }
public IActionResult Contacts(ContactsInputModel model) { this.AddTagsToViewBag(this.tags); this.ViewBag.MailSend = false; this.ViewBag.PageDescription = "За контакти и въпроси при направа на чаша може да се свържете с нас."; this.ViewBag.FashShippingEnabled = bool.Parse(this.configuration["AppSettings:FastShippingEnabled"]); var captcha = this.HttpContext.Request.Form["g-recaptcha-response"].FirstOrDefault(); if (this.ModelState.IsValid && !string.IsNullOrWhiteSpace(captcha)) { using (var wb = new WebClient()) { var data = new NameValueCollection(); data["secret"] = configuration["AppSettings:ReCaptchaSecretKey"]; data["response"] = captcha; var url = configuration["AppSettings:ReCaptchaUrl"]; var response = wb.UploadValues(url, "POST", data); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; var googleResponse = JsonSerializer.Deserialize <ReCaptchaV2Dto>(Encoding.UTF8.GetString(response), options); if (googleResponse.Success == true) { this.feedbacks.Add(new Data.Models.Feedback() { Name = model.Name, Email = model.Email, Text = model.Comment, IsNew = true }); this.ViewBag.MailSend = true; } } } var viewModel = new ContactsViewModel() { Email = configuration["AppSettings:ContactsEmail"], Phone = configuration["AppSettings:ContactsPhone"], SiteKey = configuration["AppSettings:ReCaptchaSiteKey"] }; return(this.View(viewModel)); }
public async Task <IActionResult> Index() { if (this.User.Identity.IsAuthenticated == true) { var user = await this.userManager.GetUserAsync(this.User); var email = await this.userManager.GetEmailAsync(user); var viewModel = new ContactsInputModel { Email = email }; return(this.View(viewModel)); } return(this.View()); }
public async Task <IActionResult> SendEmail(ContactsInputModel inputModel) { await this.emailSender.SendEmailAsync(inputModel.Email, inputModel.Name, FitnessEmail, "Contact request", inputModel.Content); return(this.RedirectToAction("Index")); }