public ActionResult Index(ContactFormVM model) { var errors = ModelState.Values.SelectMany(v => v.Errors); if (ModelState.IsValid) { // Aanmaak van de email string body = "<p>Beste,</br></p><p>U kreeg een nieuwe contactaanvraag vanwege {0} {1}.</br></p><p>TEL / GSM: {2} en Email: {3}.</p><p><u>Boodschap:</u></br></p><p>{4}</p><p></br>Met vriendelijke groeten,</br></p><p>Uw webmaster</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); message.To.Add(new MailAddress("*****@*****.**")); message.To.Add(new MailAddress("*****@*****.**")); message.Subject = string.Format("Nieuw contactformulier van website Ivo Bytes"); message.Body = string.Format(body, model.RelFirstName, model.RelName, model.RelPhone, model.RelEmail, model.Message); message.IsBodyHtml = true; // Versturen van de mail via smtpClient => configuratie in web.config SmtpClient smtp = new SmtpClient(); smtp.Send(message); // Gebruik van Tempdata om Indexpagina te voorzien met een melding wanneer mail gestuurd werd. TempData["Success"] = "Bedankt voor uw feedback! Deze werd succesvol doorgemaild."; return(RedirectToAction("Index")); } return(View()); }
public ActionResult Edit(int id) { ContactFormVM model = new ContactFormVM() { contactFormsList = db.contactForms.ToList(), contactFormSingle = db.contactForms.FirstOrDefault(m => m.Id == id), Action = "Edit" }; return(View("Index", model)); }
public ActionResult Index() { ContactFormVM model = new ContactFormVM() { contactFormsList = db.contactForms.ToList(), contactFormSingle = null, Action = null }; return(View(model)); }
public ActionResult Contact(string vin) { var model = new ContactFormVM(); if (!string.IsNullOrEmpty(vin)) { model.ContactForm = new ContactForm { FormMessage = vin }; } return(View(model)); }
public void FileOperations_ProcessingVcardPeople_Test() { var message = ""; var cForm = new ContactFormVM(); cForm.ChosenContact = new Contact(); var list = FileOperations.FileCutting(@"C:\Users\Laci\Desktop\TesztVcard.vcf"); foreach (var item in list) { FileOperations.ProcessingVcardPeople(item, cForm.ChosenContact); } Assert.IsTrue(cForm.ChosenContactValidate(out message)); Assert.IsTrue(string.IsNullOrEmpty(message)); }
public void ContactFormVM_IsModified_Test() { ContactFormVM contact = new ContactFormVM() { ChosenContact = new Contact() { Name = "Valaki", Email = "*****@*****.**", Phone = "06791111111" } }; contact.CopyContact(); contact.ChosenContact.Name = "Valaki Más"; Assert.AreEqual(true, contact.IsModified()); }
public void ContactFormVM_ChosenContactValidation_Test() { ContactFormVM contact = new ContactFormVM() { ChosenContact = new Contact() { Name = "Valaki", Email = "", Phone = "06791111111" } }; var message = ""; contact.ChosenContactValidate(out message); Assert.AreEqual("A email cím nincs kitöltve!", message); }
public void ContactFormVM_CopyContact_Test() { ContactFormVM contact = new ContactFormVM() { ChosenContact = new Contact() { Name = "Valaki", Email = "*****@*****.**", Phone = "06791111111" } }; contact.CopyContact(); Assert.AreEqual(contact.ChosenContact.Name, contact.BackupContact.Name); Assert.AreEqual(contact.ChosenContact.Phone, contact.BackupContact.Phone); Assert.AreEqual(contact.ChosenContact.Email, contact.BackupContact.Email); }
public async Task <IActionResult> SendMail([FromBody] ContactFormVM model) { //choose service email var serviceEmail = _db.ServiceEmails.FirstOrDefault(t => t.IsDisabled == null); string messageBody = $"Name: {model.Name}<br>Phone: {model.Phone}<br>Email: {model.Email}<br><br> {model.Message}"; //save contactform info var contactForm = _mapper.Map <ContactForm>(model); _db.ContactForms.Add(contactForm); await _db.SaveChangesAsync(); Mailler mailler = new Mailler(); await mailler.SendMailAsync(serviceEmail.Email, serviceEmail.Password, "Customer", messageBody); return(Ok()); }
public ActionResult Contact(ContactFormVM model) { if (ModelState.IsValid) { ContactFormManager manager = ContactFormManagerFactory.Create(); var response = manager.AddContactForm(model.ContactForm); if (!response.Success) { return(new HttpStatusCodeResult(500, $"Error in cloud. {response.Message}")); } else { return(RedirectToAction("Index")); } } else { return(View("Contact", model)); } }