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, ArtistStoreContext artistStore, GenreStoreContext genreStore,
YearStoreContext yearStore) YearStoreContext yearStore)
{ {
var oldSongRecord = songStore.GetSong(song.Id); try
song.SongPath = oldSongRecord.SongPath; {
var oldSongRecord = songStore.GetSong(song);
song.SongPath = oldSongRecord.SongPath;
MetadataRetriever updateMetadata = new MetadataRetriever(); MetadataRetriever updateMetadata = new MetadataRetriever();
updateMetadata.UpdateMetadata(song, oldSongRecord); updateMetadata.UpdateMetadata(song, oldSongRecord);
var updatedSong = updateMetadata.UpdatedSongRecord; var updatedSong = updateMetadata.UpdatedSongRecord;
// TODO: Add the following methods // TODO: Add the following methods
// UpdateAlbumInDatabase(oldSongRecord, newSongRecord, albumStore) UpdateAlbumInDatabase(oldSongRecord, updatedSong, albumStore);
// UpdateArtistInDatabase(oldSongRecord, newSongRecord, artistStore // UpdateArtistInDatabase(oldSongRecord, newSongRecord, artistStore
// UpdateeGenreInDatabase(oldSongRecord, newSongRecord, genreStore) // UpdateeGenreInDatabase(oldSongRecord, newSongRecord, genreStore)
// UpdateYearInDatabase(oldSongRecord, newSongRecord, yearStore) // UpdateYearInDatabase(oldSongRecord, newSongRecord, yearStore)
// UpdateSongInDatabase(oldSongRecord, newSongRecord, songStore) // UpdateSongInDatabase(oldSongRecord, newSongRecord, songStore)
}
catch (Exception ex)
{
var msg = ex.Message;
_logger.Error(msg, "An error occurred");
}
return new SongResult(); return new SongResult();
} }
@@ -712,6 +720,28 @@ namespace Icarus.Controllers.Managers
song.YearId = year.YearId; 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() private async Task PopulateSongDetails()
{ {
foreach (DataRow row in _results.Rows) foreach (DataRow row in _results.Rows)
+10 -1
View File
@@ -128,9 +128,12 @@ namespace Icarus.Controllers.Utilities
{ {
Console.WriteLine($"Updating metadata of {title}"); Console.WriteLine($"Updating metadata of {title}");
_logger.Info($"Updating metadata of {title}"); _logger.Info($"Updating metadata of {title}");
foreach (var key in checkedValues.Keys) foreach (var key in checkedValues.Keys)
{ {
bool result = checkedValues[key]; bool result = checkedValues[key];
if (!result) if (!result)
{ {
switch (key.ToLower()) switch (key.ToLower())
@@ -158,7 +161,9 @@ namespace Icarus.Controllers.Utilities
} }
} }
} }
fileTag.Save(); fileTag.Save();
Console.WriteLine("Successfully updated metadata"); Console.WriteLine("Successfully updated metadata");
_logger.Info("Successfully updated metadata"); _logger.Info("Successfully updated metadata");
} }
@@ -232,7 +237,11 @@ namespace Icarus.Controllers.Utilities
songValues["Artists"] = String.IsNullOrEmpty(song.Artist); songValues["Artists"] = String.IsNullOrEmpty(song.Artist);
songValues["Album"] = String.IsNullOrEmpty(song.AlbumTitle); songValues["Album"] = String.IsNullOrEmpty(song.AlbumTitle);
songValues["Genre"] = String.IsNullOrEmpty(song.Genre); songValues["Genre"] = String.IsNullOrEmpty(song.Genre);
if (song.Year==0) if (song.Year == null)
{
songValues["Year"] = true;
}
else if (song.Year==0)
{ {
songValues["Year"] = true; songValues["Year"] = true;
} }