public async Task <ActionResult> AddPage(string data, string fieldPrefix, string newUrl) { // Validation UrlValidationAttribute attr = new UrlValidationAttribute(UrlValidationAttribute.SchemaEnum.Any, UrlTypeEnum.Local); if (!attr.IsValid(newUrl)) { throw new Error(attr.ErrorMessage); } // check duplicates List <ListOfLocalPagesEditComponent.Entry> list = Utility.JsonDeserialize <List <ListOfLocalPagesEditComponent.Entry> >(data); if ((from l in list where l.Url.ToLower() == newUrl.ToLower() select l).FirstOrDefault() != null) { throw new Error(this.__ResStr("dupUrl", "Url {0} has already been added", newUrl)); } // add new grid record ListOfLocalPagesEditComponent.Entry entry = new ListOfLocalPagesEditComponent.Entry(newUrl); return(await GridRecordViewAsync(await ListOfLocalPagesEditComponent.GridRecordAsync(fieldPrefix, entry))); }
public void GetValidator() { UrlValidationAttribute urlValidationAttribute = new UrlValidationAttribute(); Assert.IsInstanceOf(typeof(UrlValidator), urlValidationAttribute.GetValidator()); }