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); } }); })); }
public static void SetPlaylist(PlaylistTrack track) { MusicDataContext.WithSubmit(db => { Clear(db); Add(db, track); SetIndex(db, 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); } }); }
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); } }); })); }
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; } })); }
public static void SetIndex(int newIndex) { MusicDataContext.WithSubmit(db => { SetIndex(db, newIndex); }); }
public static void AddAll(IEnumerable <PlaylistTrack> tracks) { MusicDataContext.WithSubmit(db => { Add(db, tracks); }); }
public static void Clear() { MusicDataContext.WithSubmit(db => { Clear(db); }); }