Ejemplo n.º 1
0
 public void RemovePlaylist(Playlist ipl)
 {
     using (var db = new SQLiteConnection(Tables.DBPath))
     {
         if (ipl != null)
         {
             var p = new Library.TableModels.Playlist();
             p.ID   = ipl.ID;
             p.Path = ipl.Path;
             db.Delete(p);
         }
     }
 }
Ejemplo n.º 2
0
 public void Save(Bridge.Playlist playlist, List <TrackViewModel> lst)
 {
     using (var db = new SQLiteConnection(Tables.DBPath))
     {
         try
         {
             if (!string.IsNullOrEmpty(playlist.ID))                     //already a member in DB
             {
                 playlist.Write(TranslateList(lst));                     //save to given path
                 //Now check if the given path was the original path or
                 //a different one
                 //if (db.Table<Library.TableModels.Playlist>().Where(c => c.ID == playlist.ID).First().Path != playlist.Path)
                 //{
                 //delete old playlist, since new one is already saved
                 string f = db.Table <Library.TableModels.Playlist>().Where(c => c.ID == playlist.ID).First().Path;
                 //if (File.Exists(f)) File.Delete(f);
                 var p = new Library.TableModels.Playlist();
                 p.ID   = playlist.ID;
                 p.Path = playlist.Path;
                 p.Name = playlist.Name;
                 db.Update(p);
                 //}
             }
             else                     //not a member in DB means its a new playlist
             {
                 playlist.ID = Guid.NewGuid().ToString();
                 playlist.Write(TranslateList(lst));
                 var p = new Library.TableModels.Playlist();
                 p.ID   = playlist.ID;
                 p.Path = playlist.Path;
                 p.Name = playlist.Name;
                 db.Insert(p);
             }
         }
         catch (Exception e)
         {
         }
     }
 }