예제 #1
0
 public override Task AddPlayCount(string songPath)
 {
     return(TaskEx.Run(() => {
         MusicDataContext.WithSubmit(db => {
             var currentEntry = from PlayFrequency playFreq in db.PlayFrequencies
                                where playFreq.SongPath == songPath
                                select playFreq;
             if (currentEntry.Any())
             {
                 // if the entry already exists
                 foreach (PlayFrequency pf in currentEntry)
                 {
                     pf.PlayCount = pf.PlayCount + 1;
                 }
             }
             else
             {
                 // if it doesn't exist
                 var newEntry = new PlayFrequency()
                 {
                     SongPath = songPath, PlayCount = 1
                 };
                 db.PlayFrequencies.InsertOnSubmit(newEntry);
             }
         });
     }));
 }
예제 #2
0
 public static void SetPlaylist(PlaylistTrack track)
 {
     MusicDataContext.WithSubmit(db => {
         Clear(db);
         Add(db, track);
         SetIndex(db, 0);
     });
 }
예제 #3
0
 /// <summary>
 /// http://stackoverflow.com/questions/2801500/linq-display-row-numbers
 /// </summary>
 /// <param name="index"></param>
 public static void Delete(int index)
 {
     MusicDataContext.WithSubmit(db => {
         var songs = (from PlaylistItem song in db.Playlist orderby song.ItemId select song)
                     .AsEnumerable();
         if (songs != null && songs.Count() > index)
         {
             var song = songs.ElementAt(index);
             db.Playlist.DeleteOnSubmit(song);
         }
     });
 }
예제 #4
0
 public override Task DeleteSongEntry(string songPath)
 {
     return(TaskEx.Run(() => {
         MusicDataContext.WithSubmit(db => {
             var entry = from PlayFrequency playFreq in db.PlayFrequencies
                         where playFreq.SongPath == songPath
                         select playFreq;
             foreach (PlayFrequency pf in entry)
             {
                 db.PlayFrequencies.DeleteOnSubmit(pf);
             }
         });
     }));
 }
예제 #5
0
 public static PlaylistTrack Previous()
 {
     return(MusicDataContext.WithSubmit(db => {
         var index = Index(db);
         var tracks = Tracks(db);
         if (index > 0 && tracks.Count > --index)
         {
             var track = tracks[index];
             SetIndex(db, index);
             return track;
         }
         else
         {
             return null;
         }
     }));
 }
예제 #6
0
 public static void SetIndex(int newIndex)
 {
     MusicDataContext.WithSubmit(db => {
         SetIndex(db, newIndex);
     });
 }
예제 #7
0
 public static void AddAll(IEnumerable <PlaylistTrack> tracks)
 {
     MusicDataContext.WithSubmit(db => {
         Add(db, tracks);
     });
 }
예제 #8
0
 public static void Clear()
 {
     MusicDataContext.WithSubmit(db => {
         Clear(db);
     });
 }