public void UpdateEntry(MediaLibraryEntry entry) { using (var context = new SqliteDbContext(settings)) { context.Update(entry); context.SaveChanges(); } }
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(); } }
public long GetFileCount() { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries .Where(e => !e.IsFolder) .Count()); } }
public MediaLibraryEntry GetEntryByPath(string fullName) { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries .Where(e => e.Path == fullName) .SingleOrDefault()); } }
public MediaLibraryEntry GetEntry(int id) { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries .Where(e => e.Id == id) .SingleOrDefault()); } }
public IEnumerable <MediaLibraryEntry> GetChildEntries(int id) { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries .Where(e => e.ParentId == id) .ToArray()); } }
public IEnumerable <MediaLibraryEntry> GetRootFolders() { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries .Where(e => e.IsFolder) .Where(e => e.ParentId == -1) .ToArray()); } }
public int AddEntry(MediaLibraryEntry entry) { using (var context = new SqliteDbContext(settings)) { context.Add(entry); context.SaveChanges(); return(entry.Id); } }
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); } }
public IEnumerable <MediaLibraryEntry> GetAllEntries() { using (var context = new SqliteDbContext(settings)) { return(context.LibraryEntries.ToArray()); } }