protected override ValidationResult IsValid(object value, ValidationContext validationContext) { HtmlHelperDbEntities db = new HtmlHelperDbEntities(); string emailValor = (string)value; int count = db.Usuario.Where(x => x.Email == emailValor).ToList().Count(); if (count != 0) { return(new ValidationResult("Ya existe un usuario con ese correo electrónico")); } return(ValidationResult.Success); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { HtmlHelperDbEntities db = new HtmlHelperDbEntities(); var emailValor = (string)value; int unico = db.Persona.Where(x => x.Email == emailValor).ToList().Count(); if (unico != 0) { return(new ValidationResult("Ya hay una persona con este correo electrónico")); } return(ValidationResult.Success); }