Beispiel #1
0
        public static async Task <DatabaseVirtualFolder> GetParentOfFolderAsync(string id)
        {
            DatabaseVirtualFolder result        = new DatabaseVirtualFolder();
            SqliteCommand         selectCommand = new SqliteCommand
                                                      ($"SELECT * FROM VIRTUALFOLDER WHERE Id IN (SELECT PARENT_Id FROM VIRTUALFOLDER_RELATION WHERE CHILD_Id={id})", Database);

            SqliteDataReader query = await selectCommand.ExecuteReaderAsync();

            if (!query.HasRows)
            {
                return(null);
            }

            while (query.Read())
            {
                DatabaseVirtualFolder folder = new DatabaseVirtualFolder()
                {
                    Id   = query.GetInt32(0),
                    Name = query.GetString(1)
                };

                result = folder;
            }

            return(result);
        }
Beispiel #2
0
        public static async Task <DatabaseVirtualFolder> InsertVirtualFolderAsync(string name, int parentId = -1)
        {
            DatabaseVirtualFolder result = new DatabaseVirtualFolder()
            {
                Name = name
            };

            using (SqliteCommand command = new SqliteCommand("INSERT INTO VIRTUALFOLDER (name) " +
                                                             $"VALUES ('{name}')", Database))
            { await command.ExecuteReaderAsync(); }

            Int64 rowid = 0;

            using (SqliteCommand command = new SqliteCommand("SELECT last_insert_rowid()", Database))
            { rowid = (Int64)await command.ExecuteScalarAsync(); }

            if (rowid == 0)
            {
                throw new SqliteException("SQLite access exception: Something went wrong!", 1);
            }
            if (parentId > -1)
            {
                using (SqliteCommand command = new SqliteCommand("INSERT INTO VIRTUALFOLDER_RELATION (PARENT_Id, CHILD_Id) " +
                                                                 $"VALUES ({parentId}, {rowid})", Database))
                { await command.ExecuteReaderAsync(); }
            }

            result.Id = (int)rowid;

            return(result);
        }
Beispiel #3
0
        public static async Task <List <DatabaseVirtualFolder> > GetChildrenOfFolderAsync(string id)
        {
            List <DatabaseVirtualFolder> result = new List <DatabaseVirtualFolder>();

            SqliteCommand selectCommand = new SqliteCommand
                                              ($"SELECT * FROM VIRTUALFOLDER WHERE Id IN (SELECT CHILD_Id FROM VIRTUALFOLDER_RELATION WHERE PARENT_Id={id})", Database);

            SqliteDataReader query = await selectCommand.ExecuteReaderAsync();


            while (query.Read())
            {
                DatabaseVirtualFolder folder = new DatabaseVirtualFolder()
                {
                    Id   = query.GetInt32(0),
                    Name = query.GetString(1)
                };

                result.Add(folder);
            }

            return(result);
        }
Beispiel #4
0
 public static async Task <int> GetImagesCountInFolderAsync(DatabaseVirtualFolder folder)
 {
     return(await GetImagesCountInFolderAsync(folder.Id));
 }
Beispiel #5
0
 public static async Task <List <Tuple <int, string> > > GetImagesInFolderAsync(DatabaseVirtualFolder folder)
 {
     return(await GetImagesInFolderAsync(folder.Id));
 }
Beispiel #6
0
 public static async Task <DatabaseVirtualFolder> GetParentOfFolderAsync(DatabaseVirtualFolder folder)
 {
     return(await GetParentOfFolderAsync(folder.Id));
 }
Beispiel #7
0
 public static async Task <List <DatabaseVirtualFolder> > GetChildrenOfFolderAsync(DatabaseVirtualFolder folder)
 {
     return(await GetChildrenOfFolderAsync(folder.Id));
 }