Exemple #1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            UserLogin userLogin = (UserLogin)validationContext.ObjectInstance;

            APIMessage apiMessage = APIInterface.IsUsernameInDb(userLogin.username).GetAwaiter().GetResult();

            if (apiMessage.Message == "That username is currently available.")
            {
                return(new ValidationResult("That username is not currently found in the database"));
            }

            return(ValidationResult.Success);
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var registerViewModel = (RegisterViewModel)validationContext.ObjectInstance;

            APIMessage apiMessage = APIInterface.IsUsernameInDb(registerViewModel.Username).GetAwaiter().GetResult();

            if (apiMessage.Message == "User with that username already exists.")
            {
                return(new ValidationResult("That username is currently registered to another user"));
            }

            return(ValidationResult.Success);
        }