private List<string> ValidateEmail(FormEmail email) { List<string> errors = new List<string>(); ValueExists("Email", email.Email, errors); // IsPatternValid("Email", email.Email, new Regex(@"/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/", RegexOptions.IgnoreCase), errors); // IsPatternValid("Email", email.Email, new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*@((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$", RegexOptions.IgnoreCase), errors); IsPatternValid("Email", email.Email, new Regex(@"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$", RegexOptions.IgnoreCase), errors); return errors; }
private List<string> ValidateConfirmEmail(FormEmail email) { List<string> errors = new List<string>(); ValueExists("ConfirmEmail", email.ConfirmEmail, errors); ConfirmEmailMatch("ConfirmEmail", email.Email, email.ConfirmEmail, errors); return errors; }
public List<string> SetUnsubscribeDataAddress(FormEmail email, FormAddress address, string sourceCode) { AuditTrail auditTrail = new AuditTrail(); List<string> errors = null; HCPIndividual hcp; QuestionResponseSet questionResponseSet; try { errors = ValidateAddress(address); errors.AddRange(ValidateEmail(email)); if (errors.Count > 0) { auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_error, "SetUnsubscribeDataAddress", errors.ToString()); return errors; } if (Services.ServiceIsAvailable) { EmailAddress emailAddress = new EmailAddress(email.Email); Address Address = new Address(address.Address1, address.Address2, address.City, address.State, address.Zip, "", ""); hcp = new HCPIndividual(); hcp.FirstName = address.FName; hcp.LastName = address.LName; hcp.MiddleName = address.MName; hcp.Addresses = new List<Address>(); hcp.Addresses.Add(Address); hcp.EmailAddresses = new List<EmailAddress>(); hcp.EmailAddresses.Add(emailAddress); RegistrationManager regMgr = new RegistrationManager(); regMgr.Individual = hcp; string sourceMCC = string.Empty; if (!string.IsNullOrWhiteSpace(sourceCode) && !string.Equals(sourceCode, "0")) { sourceMCC = sourceCode; } else { sourceMCC = Convert.ToString(ConfigurationManager.AppSettings["MCCUnsubscribe"]); } List<QuestionResponse> questionResponses = new List<QuestionResponse>(); QuestionResponse questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDExitMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]), ConfigurationManager.AppSettings["MCCUnsubscribe"]); questionResponses.Add(questionResponse); questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDOptOutBEDDirectMail"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsYes"])); questionResponses.Add(questionResponse); questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDSourceMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]), sourceMCC); questionResponses.Add(questionResponse); questionResponseSet = new QuestionResponseSet(); // questionResponseSet.QuestionSetID = long.MaxValue; questionResponseSet.QuestionResponses = questionResponses; regMgr.PerformLiteRegistration(hcp, questionResponseSet); errors = GetRegMgrErrors(regMgr, errors); auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_success, "SetUnsubscribeDataAddress", regMgr.Status.ToUpper()); if (errors.Count > 0) auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_error, "SetUnsubscribeDataAddress", errors.ToString()); } else { errors.Add("The PMM services are unavailable"); } } catch (Exception e) { auditTrail.SetAuditTrail(" ", AuditTrail.OperationType.Unsubscribtion_Failure, e.Source, e.Message); throw e; } finally { log.Info(auditTrail.GetAuditTrail()); auditTrail = null; } return errors; }
private List<string> ValidateEmail(FormEmail email) { List<string> errors = new List<string>(); ValueExists("Email", email.Email, errors); IsPatternValid("Email", email.Email, new Regex(@"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$", RegexOptions.IgnoreCase), errors); return errors; }