public ActionResult ContactUsFormEdit(SendEmailContactUsModel model) { new AccountServices().SaveContactForm(model); return(RedirectToAction("CommunicationsCenter")); //TODO - validation message }
public void SaveContactForm(SendEmailContactUsModel model) { var options = this.Db.Context.ContactUsFormOptions.FirstOrDefault(); if (options == null) { options = new ContactUsFormOption(); } options.Address = model.ContactUsAddress; options.Telephone = model.ContactUsTel; var subjects = this.Db.Context.ContactUsFormSubjects.DefaultIfEmpty(); if (subjects != null) { this.Db.Context.ContactUsFormSubjects.RemoveRange(subjects); } foreach (var newsubject in model.ContactUsSubjects) { if (!String.IsNullOrEmpty(newsubject)) { ContactUsFormSubject entity = new ContactUsFormSubject { SubjectName = newsubject }; this.Db.Context.ContactUsFormSubjects.Add(entity); } } this.Db.SaveChanges(); }
public ServiceResponse GetContactForm() { var model = new SendEmailContactUsModel(); var options = this.Db.Context.ContactUsFormOptions.FirstOrDefault(); if (options != null) { model.ContactUsAddress = options.Address; model.ContactUsTel = options.Telephone; List <string> subjects = this.Db.Context.ContactUsFormSubjects.Select(x => x.SubjectName).ToList(); if (subjects != null) { model.ContactUsSubjects = subjects; } } this.Response.Model = model; return(this.Response); }
public ActionResult Contact(string name, string email, string subject, string message) { this.ServiceResponse = new ServiceResponse(); var emailModel = new SendEmailContactUsModel { UserName = name, UserEmail = email, Subject = subject, Message = message }; if (string.IsNullOrWhiteSpace(name)) { this.ServiceResponse.AddError("UserName", "Please enter your name."); } if (string.IsNullOrWhiteSpace(email)) { this.ServiceResponse.AddError("UserEmail", "Please enter your email address."); } var emailTest = Validation.IsEmail(email, "Email address", 255, true); if (emailTest != null) { this.ServiceResponse.AddError("UserEmail", emailTest); } if (string.IsNullOrWhiteSpace(subject)) { this.ServiceResponse.AddError("Subject", "Please select a subject."); } if (string.IsNullOrWhiteSpace(message)) { this.ServiceResponse.AddError("Message", "Please enter a message"); } if (message.Length > 300000) { this.ServiceResponse.AddError("Message", "Message too long"); } if (ProcessServiceResponse()) { emailModel.Subject = string.Format("A contact request received"); emailModel.From = new MailAddress(Utilities.Config("dpo.sys.email.from"), "DPO System"); emailModel.To.Add(new MailAddress(Utilities.Config("dpo.sys.email.from"), "Help Desk")); emailModel.RenderTextVersion = true; emailModel.BodyTextVersion = RenderView(this, "SendEmailContactRequest", emailModel); emailModel.RenderTextVersion = false; emailModel.BodyHtmlVersion = RenderView(this, "SendEmailContactRequest", emailModel); new EmailServices().SendEmail(emailModel); return(PartialView("RegistrationAcknowledgement", "Account")); } return(View("Contact", emailModel)); }