private void View() { Console.Clear(); Console.Write("\tPlaylist ID: "); int playlistId = Convert.ToInt32(Console.ReadLine()); IsEmptyValidation(ref playlistId); SongsRepository phonesRepository = new SongsRepository(Properties.Settings.Default.FileSongs); Playlist playlist = _playlistRepository.GetById(playlistId); if (playlist == null || playlist.IsPublic == false) { Console.Clear(); Console.WriteLine("\tPlaylist not found."); Console.ReadKey(true); } else { Console.Clear(); SongsManagerView songManagerView = new SongsManagerView(playlist); songManagerView.Show(); } }
public void EditPlaylist(PlaylistDTO playlistDto, int userId) { using (var uow = UnitOfWorkProvider.Create()) { var playlist = playlistRepository.GetById(playlistDto.ID); Mapper.Map(playlistDto, playlist); playlist.User = GetPlaylistUser(userId); playlistRepository.Update(playlist); uow.Commit(); } }
private Playlist GetSonglistPlaylist(int playlistId) { var playlist = _playlistRepository.GetById(playlistId); if (playlist == null) { throw new NullReferenceException("Songlist service - GetSonglistSong(...) song cant be null"); } return(playlist); }
private void Delete() { PlaylistRepository playlistRepository = new PlaylistRepository("playlist.txt"); Console.Clear(); Console.WriteLine("Delete Playlist:"); Console.Write("Playlist Id: "); int playlistId = Convert.ToInt32(Console.ReadLine()); Entity.Playlist playlist = playlistRepository.GetById(playlistId); if (playlist == null) { Console.WriteLine("Plylist not found!"); } else { playlistRepository.Delete(playlist); Console.WriteLine("Playlist deleted successfully."); } Console.ReadKey(true); }
private void View() { Console.Clear(); Console.Write("Playlist ID: "); int playlistId = Convert.ToInt32(Console.ReadLine()); PlaylistRepository playlistRepository = new PlaylistRepository("playlist.txt"); Entity.Playlist playlist = playlistRepository.GetById(playlistId); int lognat = AuthenticationService.LoggedUser.Id; if (playlist == null) { Console.Clear(); Console.WriteLine("Playlist not found."); Console.ReadKey(true); return; } if (playlist.IsPublic == true || playlist.ParentUserId == lognat) { Console.WriteLine("ID:" + playlist.Id); Console.WriteLine("Name :" + playlist.Name); Console.WriteLine("Description :" + playlist.Description); Console.WriteLine("Songs :" + playlist.Songs); Console.WriteLine("IsPublic :" + playlist.IsPublic); Console.WriteLine("------------------------------------"); Console.WriteLine(); } else { Console.WriteLine("This playlist is not public!"); } Console.ReadKey(true); }
private void Update() { Console.Clear(); Console.Write("Playlist ID: "); int playlistId = Convert.ToInt32(Console.ReadLine()); PlaylistRepository playlistRepository = new PlaylistRepository("playlist.txt"); Entity.Playlist playlist = playlistRepository.GetById(playlistId); if (playlist == null) { Console.Clear(); Console.WriteLine("Playlist not found."); Console.ReadKey(true); return; } Console.WriteLine("Editing Playlist (" + playlist.Name + ")"); Console.WriteLine("ID:" + playlist.Id); Console.WriteLine("Name :" + playlist.Name); Console.Write("New Name:"); string Name = Console.ReadLine(); Console.WriteLine("Description :" + playlist.Description); Console.Write("New Description :"); string Description = Console.ReadLine(); Console.WriteLine("IsPublic :" + playlist.IsPublic); Console.Write("New IsPublic :"); string IsPublic = Console.ReadLine(); Console.WriteLine("Add or Remove songs ?"); string answer = Console.ReadLine(); if (answer.ToLower() == "add") { Console.Write("Add Song by Song ID :"); int songId = Convert.ToInt32(Console.ReadLine()); SongsRepository songsRepository = new SongsRepository("songs.txt"); Entity.Song song = songsRepository.GetById(songId); if (song == null) { Console.Clear(); Console.WriteLine("Song not found."); Console.ReadKey(true); return; } playlist.Songs += " / " + song.Title + ", " + song.ArtistName + ", " + song.Year + " y."; Console.WriteLine("You add the song : " + song.Title + ", " + song.ArtistName + ", " + song.Year + " y. to your playlist!"); } else if (answer.ToLower() == "remove") { Console.Write("Remove Song by Song Index in Playlist :"); int songId = Convert.ToInt32(Console.ReadLine()); //playlist.Songs; } if (!string.IsNullOrEmpty(Name)) { playlist.Name = Name; } if (!string.IsNullOrEmpty(Description)) { playlist.Description = Description; } playlistRepository.Save(playlist); Console.WriteLine("Playlist saved successfully."); Console.ReadKey(true); }