Esempio n. 1
0
 /// <summary>
 ///     Song information replacement
 /// </summary>
 /// <param name="song">Song to replace</param>
 public void ReplaceSong(Song song)
 {
     using (var context = new Context())
     {
         context.Tracks.Remove(context.Tracks.SingleOrDefault(t => t.PathOnUserPc == song.Path));
         context.SaveChanges();
         context.Artists.AddOrUpdate(a => a.ArtistName, new Artist
         {
             ArtistName = song.ArtistName
         });
         context.SaveChanges();
         context.Albums.AddOrUpdate(a => a.AlbumName,
             new Album
             {
                 AlbumName = song.Album
             });
         context.SaveChanges();
         context.Tracks.AddOrUpdate(t => t.PathOnUserPc,
             new Track
             {
                 TrackName = song.Title,
                 Duration = song.Duration,
                 PathOnUserPc = song.Path,
                 Album = context.Albums.SingleOrDefault(a => a.AlbumName == song.Album),
                 Artist = context.Artists.FirstOrDefault(a => a.ArtistName == song.ArtistName)
             });
         context.SaveChanges();
         DBChanged?.Invoke();
     }
 }
Esempio n. 2
0
 public ID3TagWindow(Song song)
 {
     targetSong = song;
     InitializeComponent();
     PathBox.Text = song.Path;
     AlbumBox.Text = song.Album;
     ArtistBox.Text = song.ArtistName;
     TitleBox.Text = song.Title;
 }
Esempio n. 3
0
 /// <summary>
 ///     Deleting song
 /// </summary>
 /// <param name="obj">Song to delete</param>
 public void RemoveSongFromDb(Song obj)
 {
     using (var context = new Context())
     {
         var removed = context.Tracks.FirstOrDefault(t => t.PathOnUserPc == obj.Path);
         context.Tracks.Remove(removed);
         context.SaveChanges();
         DBChanged?.Invoke();
     }
 }
 public void GetFileReturnCorrectSongList()
 {
     var testSong = new Song(
         "Hollywood Undead", " Disease", "3:32", null,
         "C:\\Users\\DarkS\\Source\\Repos\\ElQuecus\\ElQuecus\\ElQuecus.Test\\TestMusic\\Hollywood Undead - Disease.mp3"
         );
     var checkSong =
         PathToSongListConverter.GetFile(
             @"C:\Users\DarkS\Source\Repos\ElQuecus\ElQuecus\ElQuecus.Test\TestMusic\Hollywood Undead - Disease.mp3");
     Assert.IsTrue(testSong.Equals(checkSong));
 }
 /// <summary>
 ///     Converts each given track to the Song class instance
 /// </summary>
 /// <param name="path">path to the track</param>
 /// <returns></returns>
 public static Song GetFile(string path)
 {
     var tags = File.Create(path);
     if (Math.Abs(tags.Properties.Duration.TotalSeconds) <= 0)
         return null;
     var song =
         new Song(
             toUtf8(tags.Tag.FirstPerformer),
             toUtf8(tags.Tag.Title) ?? path.Substring(path.LastIndexOf('\\') + 1,
                 path.LastIndexOf('.') - path.LastIndexOf('\\') - 1),
             $"{tags.Properties.Duration.Minutes}:{tags.Properties.Duration.Seconds}",
             toUtf8(tags.Tag.Album),
             path);
     return song;
 }
Esempio n. 6
0
 public void DeleteSong(Song song) => rep.RemoveSongFromDb(song);