public void UpdateSong(SongUpdate songUpdate) { library.UpdateSongShallow(songUpdate); library.InitialiseParts(); NotifyUpdated(); }
public void RenameAlbum(SongUpdate songUpdate) { Messenger.Log("Updating album with " + songUpdate); var songs = library.GetSongsByAlbum(songUpdate.SongSource.Album); PerformUpdate(songUpdate, songs); }
public void RenameArtist(SongUpdate songUpdate) { Messenger.Log("Updating artist with " + songUpdate); var songs = library.GetSongsByArtist(songUpdate.SongSource.Artist); PerformUpdate(songUpdate, songs); }
private void PerformUpdate(SongUpdate songUpdate, IList <Song> songs) { foreach (var song in songs) { var update = songUpdate.CloneWith(song); library.UpdateSongShallow(update); } if (songs.Count <= 0) { return; } library.InitialiseParts(); NotifyUpdated(); }
public InfoWindow(SongUpdate song, InfoType info) { InitializeComponent(); DataContext = song; SongData = song; if (info == InfoType.Album) { songBox.Visibility = Visibility.Hidden; } if (info == InfoType.Artist) { songBox.Visibility = Visibility.Hidden; albumBox.Visibility = Visibility.Hidden; } }
public ActionResult Update(int id) { var _service = CreateSongService(); var detail = _service.GetSongById(id); var model = new SongUpdate { SongId = detail.SongId, Title = detail.Title, ArtistId = detail.ArtistId, GenreId = detail.GenreId, //Album = detail.Album, Date = detail.Date }; return(View(model)); }
public bool UpdateSong(SongUpdate model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Songs.Find(model.SongId); int?artistId = entity.ArtistId; int genreId = entity.GenreId; //int albumId = entity.AlbumId; entity.Title = model.Title; entity.Date = model.Date; entity.ArtistId = model.ArtistId; entity.GenreId = model.GenreId; //entity.AlbumId = model.AlbumId; if (artistId != entity.ArtistId) { var artistEntity = ctx.Artists.Find(artistId); artistEntity.SongsByArtist.Remove(entity); var newArtistEntity = ctx.Artists.Find(entity.ArtistId); newArtistEntity.SongsByArtist.Add(entity); } if (genreId != entity.GenreId) { var genreEntity = ctx.Genres.Find(genreId); genreEntity.SongsInGenre.Remove(entity); var newGenreEntity = ctx.Genres.Find(entity.GenreId); newGenreEntity.SongsInGenre.Add(entity); } //if (albumId != entity.AlbumId) //{ // var albumEntity = ctx.Albums.Find(albumId); // albumEntity.SongsInAlbum.Remove(entity); // var newAlbumEntity = ctx.Albums.Find(entity.AlbumId); // newAlbumEntity.SongsInAlbum.Add(entity); //} return(ctx.SaveChanges() == 1); } }
protected override void ControlledExecute(object parameter) { var updateData = view.PromptSongData(InfoType.Artist); if (updateData == null || updateData.NewArtist == updateData.SongSource.Artist) { return; } var songs = controller.Browser.GetSongsByArtist(updateData.SongSource.Artist); foreach (var song in songs) { var update = new SongUpdate(song) { NewArtist = updateData.NewArtist }; controller.LoadHandler.UpdateSong(update); } }
protected override void ControlledExecute(object parameter) { var infoType = (InfoType)parameter; Messenger.Log("Editing " + infoType + ". Opening data prompt"); SongUpdate update = view.PromptSongData(infoType); Messenger.Log("Prompt closed. " + update); if (update != null) { switch (infoType) { case InfoType.Album: update.NewName = null; controller.LoadHandler.RenameAlbum(update); model.SelectionTracker.SelectedAlbum = update.NewAlbum; model.SelectionTracker.SelectedArtist = update.ToSong().Artist; Messenger.Log("Album updated"); break; case InfoType.Artist: update.NewName = null; update.NewAlbum = null; controller.LoadHandler.RenameArtist(update); model.SelectionTracker.SelectedArtist = update.NewArtist; Messenger.Log("Artist updated"); break; case InfoType.Song: controller.LoadHandler.UpdateSong(update); var updatedSong = update.ToSong(); model.SelectionTracker.SelectedSong = updatedSong; Messenger.Log("Song updated to: " + updatedSong.Artist + " " + updatedSong.Album + " " + updatedSong.Name); break; default: throw new ArgumentOutOfRangeException(); } } }
public ActionResult Update(int id, SongUpdate model) { if (!ModelState.IsValid) { return(View(model)); } if (model.SongId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var _service = CreateSongService(); if (_service.UpdateSong(model)) { TempData["SaveResult"] = "Your song was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your song could not be updated."); return(View(model)); }
private void okButton_Click(object sender, RoutedEventArgs e) { SongData = DataContext as SongUpdate; DialogResult = true; Close(); }
internal void UpdateSongShallow(SongUpdate edit) { RemoveById(edit.SongSource.ID); AddSong(CreateSongFromUpdate(edit)); }
public void UpdateSong(SongUpdate edit) { DeleteSong(edit.SongSource); AddSong(CreateSongFromUpdate(edit)); }
private Song CreateSongFromUpdate(SongUpdate edit) { return(new Song(edit.NewArtist, edit.NewAlbum, edit.NewName, edit.NewTrackNo, edit.SongSource.FilePath)); }