public ActionResult Send(ContactBindingModel bindingModel) { if (!ModelState.IsValid) { var homeModel = this.service.GetHomeModel(); Mapper.Map(bindingModel, homeModel.ContactModelBg); return(View("Index", homeModel)); } bool success = this.service.SendContactEmail(bindingModel); if (success) { this.ViewBag.Header = PublicMessages.MessageSentHeaderBg; this.ViewBag.Paragraph = PublicMessages.MessageSentParagraphBg; return(View("MessagePage")); } else { this.ViewBag.Header = PublicMessages.MessageNotSentHeaderBg; this.ViewBag.Paragraph = PublicMessages.MessageNotSentParagraphBg; return(View("MessagePage")); } }
public async Task <IActionResult> Contact(ContactBindingModel model) { await this.contactService.AddContactMessage(model); this.TempData["Success"] = $"Thank you for your feedback. Your message will be proccessed and replied if needed!"; return(this.View()); }
public bool SendContactEmail(ContactBindingModel contactModel) { var emailer = new Emailer(MailSettings.SensatoSettings); string body = $"Name: {contactModel.Name}{Environment.NewLine}Phone: {contactModel.PhoneNumber}{Environment.NewLine}Email: {contactModel.Email}{Environment.NewLine}{contactModel.Message}"; string subject = contactModel.Subject; return(emailer.SendEmail(body, subject, false, MailSettings.SensatoEmail)); }
public async Task <bool> AddContactMessage(ContactBindingModel model) { var message = AutoMapper.Mapper.Map <ContactMessage>(model); await this.context.AddAsync(message); var result = await this.context.SaveChangesAsync(); return(result > 0); }
public IActionResult Info(ContactBindingModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } this.emailSender.SendEmailAsync(ReceivingEmail, $"{model.Email}", $"<p>Subject:{model.Subject} <br />Message:{model.Message}</p>"); return(this.Redirect("/Home/Index")); }
public async Task <IActionResult> Contact(ContactBindingModel model) { if (!ModelState.IsValid) { return(View()); } await emailSender.SendEmailAsync(model.Email, model.Subject, model.Message); //StatusMessage = "Email sent. We will contact you as soon as possible."; return(RedirectToAction("Index")); }
private ContactBindingModel GetMessageModel() { ContactBindingModel model = new ContactBindingModel { Email = "*****@*****.**", Message = "Test message for testing purposes", Name = "Test Testing", Subject = "Test Subject", }; return(model); }
public void Delete(ContactBindingModel model) { try { using (var command = new NpgsqlCommand("DELETE FROM contact WHERE id = @id", source.npgsqlConnection)) { command.Parameters.AddWithValue("id", model.Id); command.ExecuteNonQuery(); } } catch (Exception) { throw; } }
public IActionResult Contact(ContactBindingModel model) { if (ModelState.IsValid) { //to do security check var attachment = new FormFileCollection(); if (model.UploadImage != null) { attachment.Add(model.UploadImage); } string content = $"<p><strong>Unregistered User</strong></p><p><strong> Full Name:</strong> {model.FullName} </p>" + $"<p><strong>Phone: </strong>{model.Phone}</p><p><p><strong>Email:</strong>{model.Email}</p><p><strong> Message:</strong ></p><p>{model.Message}</p>"; var message = new MailMessage(new string[] { model.Email }, //to do change email "Photo Album Contact Form", content, attachment); _emailSender.SendEmail(message); return(RedirectToAction(nameof(ContactSent))); } return(View(model)); }
public void Create(ContactBindingModel model) { int?maxId = null; using (var command = new NpgsqlCommand("select max(id) from field_medicine", source.npgsqlConnection)) { var reader = command.ExecuteReader(); reader.Read(); maxId = reader.GetInt32(0); reader.Close(); } if (!maxId.HasValue) { maxId = 200; } using (var command = new NpgsqlCommand("INSERT INTO contact (id, telephone) VALUES (@id, @telephone)", source.npgsqlConnection)) { command.Parameters.AddWithValue("id", maxId + 1); command.Parameters.AddWithValue("telephone", model.Telephone); command.ExecuteNonQuery(); } }
public async Task <IActionResult> Contact() { ContactBindingModel model = new ContactBindingModel(); return(this.View(model)); }