public async Task <ActionResult> AddEmailAddressHTML(string data, string fieldPrefix, string newEmailAddress) { // Validation EmailValidationAttribute attr = new EmailValidationAttribute(); if (!attr.IsValid(newEmailAddress)) { throw new Error(attr.ErrorMessage); } List <ListOfEmailAddressesEditComponent.Entry> list = Utility.JsonDeserialize <List <ListOfEmailAddressesEditComponent.Entry> >(data); if ((from l in list where l.EmailAddress.ToLower() == newEmailAddress.ToLower() select l).FirstOrDefault() != null) { throw new Error(this.__ResStr("dupEmail", "Email address {0} has already been added", newEmailAddress)); } // add new grid record ListOfEmailAddressesEditComponent.Entry entry = new ListOfEmailAddressesEditComponent.Entry { EmailAddress = newEmailAddress, }; return(await GridRecordViewAsync(await ListOfEmailAddressesEditComponent.GridRecordAsync(fieldPrefix, entry))); }
public void GetValidator() { EmailValidationAttribute emailValidationAttribute = new EmailValidationAttribute(); Assert.IsInstanceOf(typeof(EmailValidator), emailValidationAttribute.GetValidator()); }