void ITagRequestHandler.UpdateRecord( IEnumerable <BaseData> data, MusicRecord record, bool newBool) { if (data.Count() == 0) { throw new InvalidOperationException( $"Found 0 records to modify for MusicRecord {record.ToString()}"); } //BaseData firstDatum = data.First(); switch (record) { default: throw new Exception( $"Wrong field type submitted. Submitted {newBool.GetType().ToString()} for " + $"field {record.ToString()}."); } }
void ITagRequestHandler.UpdateRecord( IEnumerable <BaseData> data, MusicRecord record, double newDouble) { if (data.Count() == 0) { throw new InvalidOperationException( $"Found 0 records to modify for MusicRecord {record.ToString()}"); } foreach (BaseData datum in data) { datum.Weight = newDouble; } }
void ITagRequestHandler.UpdateRecord( IEnumerable <BaseData> data, MusicRecord record, int newInt) { if (data.Count() == 0) { throw new InvalidOperationException( $"Found 0 records to modify for MusicRecord {record.ToString()}"); } BaseData firstDatum = data.First(); switch (record) { case MusicRecord.TrackNumber: if (firstDatum is Recording) { //Updating the track number of a track recordingCommands.UpdateTrackNumber(data.Cast <Recording>(), newInt); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.AlbumYear: if (firstDatum is Album) { //Updating the year that an album was produced albumCommands.UpdateYear(data.Cast <Album>(), newInt); } else if (firstDatum is Recording) { //Updating the year that an album was produced recordingCommands.UpdateYear(data.Cast <Recording>(), newInt); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.DiscNumber: if (firstDatum is Recording) { //Updating the disc that a track appeared on recordingCommands.UpdateDiscNumber(data.Cast <Recording>(), newInt); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.RecordingType: if (firstDatum is Recording) { //Update RecordingType recordingCommands.UpdateRecordingType(data.Cast <Recording>(), (RecordingType)newInt); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; default: throw new Exception( $"Wrong field type submitted. Submitted {newInt.GetType().ToString()} for " + $"field {record.ToString()}."); } }
/// <summary> /// Make sure to translate the ID to the right context before calling this method. /// </summary> /// <param name="context"></param> /// <param name="id"></param> /// <param name="record"></param> /// <param name="newString"></param> /// <exception cref="LibraryContextException"/> void ITagRequestHandler.UpdateRecord( IEnumerable <BaseData> data, MusicRecord record, string newString) { if (data.Count() == 0) { throw new InvalidOperationException( $"Found 0 records to modify for MusicRecord {record.ToString()}"); } BaseData firstDatum = data.First(); switch (record) { case MusicRecord.SongTitle: if (firstDatum is Song) { //Renaming (or Consolidating) Songs songCommands.UpdateSongTitle(data.Cast <Song>(), newString); } else if (firstDatum is Recording) { //Splitting, Renaming, And/Or Consolidating Tracks by Song Title recordingCommands.UpdateSongTitle(data.Cast <Recording>(), newString); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.ArtistName: if (firstDatum is Artist) { //Renaming and collapsing Artists artistCommands.UpdateArtistName(data.Cast <Artist>(), newString); } else if (firstDatum is Recording) { //Assinging Songs to a different artist recordingCommands.UpdateArtistName(data.Cast <Recording>(), newString); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.AlbumTitle: if (firstDatum is Album) { //Renaming and collapsing Albums albumCommands.UpdateAlbumTitle(data.Cast <Album>(), newString); } else if (firstDatum is Recording) { //Assigning a track to a different album recordingCommands.UpdateAlbumTitle(data.Cast <Recording>(), newString); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; case MusicRecord.TrackTitle: if (firstDatum is Recording) { //Renaming and collapsing Albums recordingCommands.UpdateRecordingTitle(data.Cast <Recording>(), newString); } else { throw new LibraryContextException( $"Bad Context ({firstDatum}) for RecordUpdate ({record.ToString()})"); } break; default: throw new Exception( $"Wrong field type submitted. Submitted {newString.GetType().ToString()} for " + $"field {record.ToString()}."); } }