Exemplo n.º 1
0
 public void UpdateEntry(MediaLibraryEntry entry)
 {
     using (var context = new SqliteDbContext(settings)) {
         context.Update(entry);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public void UpdateLastPlayed(int id)
        {
            DateTime now = DateTime.UtcNow;

            using (var context = new SqliteDbContext(settings)) {
                MediaLibraryEntry entry = context.LibraryEntries
                                          .Where(e => e.Id == id)
                                          .SingleOrDefault();


                entry.LastPlayedUtc = now;

                // If this is a file, also update the parent folder
                if (!entry.IsFolder)
                {
                    entry = context.LibraryEntries
                            .Where(e => e.Id == entry.ParentId)
                            .SingleOrDefault();

                    entry.LastPlayedUtc = now;
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 3
0
 public long GetFileCount()
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries
                .Where(e => !e.IsFolder)
                .Count());
     }
 }
Exemplo n.º 4
0
 public MediaLibraryEntry GetEntryByPath(string fullName)
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries
                .Where(e => e.Path == fullName)
                .SingleOrDefault());
     }
 }
Exemplo n.º 5
0
 public MediaLibraryEntry GetEntry(int id)
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries
                .Where(e => e.Id == id)
                .SingleOrDefault());
     }
 }
Exemplo n.º 6
0
 public IEnumerable <MediaLibraryEntry> GetChildEntries(int id)
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries
                .Where(e => e.ParentId == id)
                .ToArray());
     }
 }
Exemplo n.º 7
0
 public IEnumerable <MediaLibraryEntry> GetRootFolders()
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries
                .Where(e => e.IsFolder)
                .Where(e => e.ParentId == -1)
                .ToArray());
     }
 }
Exemplo n.º 8
0
        public int AddEntry(MediaLibraryEntry entry)
        {
            using (var context = new SqliteDbContext(settings)) {
                context.Add(entry);
                context.SaveChanges();

                return(entry.Id);
            }
        }
Exemplo n.º 9
0
        public MediaLibraryEntry GetRootFolderFor(MediaLibraryEntry dir)
        {
            if (dir == null)
            {
                return(null);
            }

            using (var context = new SqliteDbContext(settings)) {
                MediaLibraryEntry rootDir = dir;
                while (rootDir.ParentId >= 0)
                {
                    rootDir = context.LibraryEntries
                              .Where(e => e.Id == rootDir.ParentId)
                              .SingleOrDefault();
                }

                return(rootDir);
            }
        }
Exemplo n.º 10
0
 public IEnumerable <MediaLibraryEntry> GetAllEntries()
 {
     using (var context = new SqliteDbContext(settings)) {
         return(context.LibraryEntries.ToArray());
     }
 }