Continuing with #37

This commit is contained in:
amazing-username
2019-05-19 02:33:57 -04:00
parent 41398461be
commit 991d2e0d6a
2 changed files with 51 additions and 12 deletions
+41 -11
View File
@@ -100,20 +100,28 @@ namespace Icarus.Controllers.Managers
ArtistStoreContext artistStore, GenreStoreContext genreStore,
YearStoreContext yearStore)
{
var oldSongRecord = songStore.GetSong(song.Id);
song.SongPath = oldSongRecord.SongPath;
try
{
var oldSongRecord = songStore.GetSong(song);
song.SongPath = oldSongRecord.SongPath;
MetadataRetriever updateMetadata = new MetadataRetriever();
updateMetadata.UpdateMetadata(song, oldSongRecord);
MetadataRetriever updateMetadata = new MetadataRetriever();
updateMetadata.UpdateMetadata(song, oldSongRecord);
var updatedSong = updateMetadata.UpdatedSongRecord;
var updatedSong = updateMetadata.UpdatedSongRecord;
// TODO: Add the following methods
// UpdateAlbumInDatabase(oldSongRecord, newSongRecord, albumStore)
// UpdateArtistInDatabase(oldSongRecord, newSongRecord, artistStore
// UpdateeGenreInDatabase(oldSongRecord, newSongRecord, genreStore)
// UpdateYearInDatabase(oldSongRecord, newSongRecord, yearStore)
// UpdateSongInDatabase(oldSongRecord, newSongRecord, songStore)
// TODO: Add the following methods
UpdateAlbumInDatabase(oldSongRecord, updatedSong, albumStore);
// UpdateArtistInDatabase(oldSongRecord, newSongRecord, artistStore
// UpdateeGenreInDatabase(oldSongRecord, newSongRecord, genreStore)
// UpdateYearInDatabase(oldSongRecord, newSongRecord, yearStore)
// UpdateSongInDatabase(oldSongRecord, newSongRecord, songStore)
}
catch (Exception ex)
{
var msg = ex.Message;
_logger.Error(msg, "An error occurred");
}
return new SongResult();
}
@@ -712,6 +720,28 @@ namespace Icarus.Controllers.Managers
song.YearId = year.YearId;
}
private void UpdateAlbumInDatabase(Song oldSongRecord, Song newSongRecord, AlbumStoreContext albumStore)
{
var albumRecord = albumStore.GetAlbum(oldSongRecord);
var oldAlbumTitle = oldSongRecord.AlbumTitle;
var newAlbumTitle = newSongRecord.AlbumTitle;
var info = string.Empty;
Console.WriteLine($"{oldAlbumTitle}\n{newAlbumTitle}");
if (!oldAlbumTitle.Equals(newAlbumTitle))
{
info = "Change to the song's album";
_logger.Info(info);
}
else
{
info = "No change to the song's album";
_logger.Info(info);
}
}
private async Task PopulateSongDetails()
{
foreach (DataRow row in _results.Rows)