Continuing with #37
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -128,9 +128,12 @@ namespace Icarus.Controllers.Utilities
|
||||
{
|
||||
Console.WriteLine($"Updating metadata of {title}");
|
||||
_logger.Info($"Updating metadata of {title}");
|
||||
|
||||
foreach (var key in checkedValues.Keys)
|
||||
{
|
||||
bool result = checkedValues[key];
|
||||
|
||||
|
||||
if (!result)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
@@ -158,7 +161,9 @@ namespace Icarus.Controllers.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileTag.Save();
|
||||
|
||||
Console.WriteLine("Successfully updated metadata");
|
||||
_logger.Info("Successfully updated metadata");
|
||||
}
|
||||
@@ -232,7 +237,11 @@ namespace Icarus.Controllers.Utilities
|
||||
songValues["Artists"] = String.IsNullOrEmpty(song.Artist);
|
||||
songValues["Album"] = String.IsNullOrEmpty(song.AlbumTitle);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user