public ActionResult Contact(string vin) { var repo = ContactRepositoryFactory.GetRepository(); var model = new ContactAddVM(); if (!string.IsNullOrEmpty(vin)) { model.Contact.Message = vin; } return(View(model)); }
public ActionResult Contact(ContactAddViewModel vm) { if (!ModelState.IsValid) { return(View(vm)); } var repo = ContactRepositoryFactory.GetRepository(); repo.Insert(vm.Contact); return(RedirectToAction("Index")); }
public ActionResult Contact(ContactAddVM model) { if (ModelState.IsValid) { var repo = ContactRepositoryFactory.GetRepository(); try { repo.Insert(model.Contact); return(View(model)); } catch (Exception ex) { throw ex; } } else { return(View(model)); } }
public ActionResult Contact(Contact contact) { var repo = ContactRepositoryFactory.GetRepository(); if ((string.IsNullOrEmpty(contact.EmailAddress)) && (string.IsNullOrEmpty(contact.TelephoneNumber))) { ModelState.AddModelError("EmailAddress", "Please enter an email address or phone number"); } if (ModelState.IsValid) { try { Contact newContact = new Contact(); newContact.ContactId = contact.ContactId; newContact.ContactName = contact.ContactName; newContact.EmailAddress = contact.EmailAddress; newContact.TelephoneNumber = contact.TelephoneNumber; newContact.ContactMessage = contact.ContactMessage; repo.Insert(newContact); TempData["Message"] = "Thank you! Your message has been received. Please allow one business day for a response."; return(RedirectToAction("Contact")); } catch (Exception ex) { throw ex; } } else { ViewBag.Message = "Your contact page."; return(View()); } }