public validationResult CredentialsAuthentication(String user, String pass)
        {
            validationResult result       = validationResult.UnknownFail;
            DbConnection     dbConnection = new DbConnection();
            String           tipoString   = "";

            using (SqlConnection connection = dbConnection.GetConnection())
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand("SELECT [Tipo_Usuario] FROM [dbo].[Usuarios] WHERE Usuario = @usuario AND Contraseña = @password", connection))
                {
                    command.Parameters.Add(new SqlParameter("@usuario", user));
                    command.Parameters.Add(new SqlParameter("@password", pass));
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        tipoString = reader["Tipo_Usuario"].ToString();
                    }

                    if (String.IsNullOrEmpty(tipoString))
                    {
                        result = validationResult.UserOrPasswordIncorrect;
                    }
                    else
                    {
                        result = validationResult.Success;
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
    public static bool CheckIsValid1(this IList <ValidationResult> valResults, int number, string family)
    {
        var validationResult = new validationResult();

        if (number > 10 || family = "akbari")
        {
            validationResult.Errors.Add(new ValidationFailure("", "Invalid Number"));
        }
        valResults.Add(validationResult);
        return(validationResult.IsValid);
    }