Exemplo n.º 1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var myUser = validationContext.ObjectInstance as T_User;

            var db = new LinkHubEntities();

            return(db.T_User.Count(x => (x.UserEmail != myUser.UserEmail && x.UserEmail == value.ToString())) > 0
                ? new ValidationResult("Email already exist")
                : ValidationResult.Success);
        }
Exemplo n.º 2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var myUrl = validationContext.ObjectInstance as T_Url;

            var db = new LinkHubEntities();

            return db.T_Url.Count(x => (x.UrlId != myUrl.UrlId && x.Url == value.ToString() )) > 0
                ? new ValidationResult("Url already exist")
                : ValidationResult.Success;
        }