// SELECT all users' files
        public List <File> SelectAllFile(string username)
        {
            string     query   = "SELECT filename, state FROM Files WHERE username = @USERNAME";
            SqlCommand command = new SqlCommand(query);

            command.Parameters.AddWithValue("USERNAME", username);

            List <File> files = new List <File>();
            File        file;

            // Mappage de la DataTable récupérée dans une liste d'objet Plan
            foreach (DataRow row in _bdd.SelectRows(command).Rows)
            {
                file = new File(row["filename"].ToString(),
                                row["state"].ToString()
                                );

                files.Add(file);
            }

            return(files);
        }
Esempio n. 2
0
        // Check existance
        public bool Exist(int id)
        {
            string     query   = "SELECT * FROM Users WHERE id = @ID";
            SqlCommand command = new SqlCommand(query);

            command.Parameters.AddWithValue("ID", id);

            if (_bdd.SelectRows(command).Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }