/// <summary> /// Method to execute save command and saves added song /// </summary> public void SaveExecute() { if (String.IsNullOrEmpty(Song.SongName) || String.IsNullOrEmpty(Song.SongAuthor) || String.IsNullOrEmpty(Song.SongDuration.ToString()) || Song.SongDuration.ToString() == "00:00:00") { MessageBox.Show("Please fill all fields to save song.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save this song?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bool isAdded = service.AddSong(User, Song); if (isAdded == true) { MessageBox.Show("Song is added.", "Notification", MessageBoxButton.OK); songView.Close(); } else { MessageBox.Show("Song cannot be added.", "Notification", MessageBoxButton.OK); songView.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void CloseAddView(object sender, EventArgs e) { _fenetreAjoutPerso.Close(); ButtonPressedEvent.GetEvent().Handler -= CloseAddView; }