Example #1
0
 public static void CleanAllData()
 {
     using (var context = new LibraryContext())
     {
         context.MediaEntries.RemoveRange(context.MediaEntries);
         context.Roots.RemoveRange(context.Roots);
         context.DevicePaths.RemoveRange(context.DevicePaths);
         context.Devices.RemoveRange(context.Devices);
         context.SaveChanges();
     }
 }
Example #2
0
        public static void ForceId3Update(this List<MediaEntry> queue)
        {
            //todo async
            using (var context = new LibraryContext())
            {
                foreach (var entry in queue)
                {

                    var tag = TagLib.File.Create(entry.FullPath);
                    entry.Artist = tag.Tag.FirstPerformer;
                    entry.Album = tag.Tag.Album;
                    entry.Title = tag.Tag.Title;
                    entry.Genre = tag.Tag.FirstGenre;
                    entry.BeatsPerMinute = tag.Properties.AudioBitrate.ToString();
                    entry.Duration = tag.Properties.Duration;

                    context.MediaEntries.Attach(entry);
                    context.Entry(entry).State = EntityState.Modified;
                }
                context.SaveChanges();
            }
        }