Example #1
0
        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();
            }
        }
Example #2
0
        private void Update()
        {
            Console.Clear();

            Console.Write("\tPlaylist ID : ");
            int playlistId = Convert.ToInt32(Console.ReadLine());

            Playlist playlist = _playlistRepository.GetById(playlistId);

            if (playlist == null)
            {
                Console.Clear();
                Console.WriteLine("\tPlaylist not found.");
                Console.ReadKey(true);
                return;
            }

            Console.WriteLine("\tEditing Playlist (" + playlist.Name + ")");
            Console.WriteLine("\tPlaylist ID : " + playlist.Id);

            Console.WriteLine("\tName : " + playlist.Name);
            Console.Write("\tNew Name : ");
            string name = Console.ReadLine();

            Console.WriteLine("\tDescription : " + playlist.Description);
            Console.Write("\tNew Description : ");
            string description = Console.ReadLine();

            if (!string.IsNullOrEmpty(name))
            {
                playlist.Name = name;
            }
            if (!string.IsNullOrEmpty(description))
            {
                playlist.Description = description;
            }

            _playlistRepository.Save(playlist);

            Console.WriteLine("\tPlaylist saved successfully.");
            Console.ReadKey(true);

            SongsManagerView songManagerView = new SongsManagerView(playlist);

            songManagerView.Show();
        }
Example #3
0
        private void Add()
        {
            Console.Clear();
            Playlist playlist = new Playlist();

            SongsManagerView songManagerView = new SongsManagerView(playlist);

            songManagerView.Show();

            Console.WriteLine("\tAdd new Playlist : ");
            Console.Write("\n");
            Console.Write("\tName : ");
            string name = Console.ReadLine();

            IsEmptyValidation(ref name);
            playlist.Name = name;

            var sessionId = AuthenticationService.LoggedUser.Id;

            playlist.UserOwnerId = sessionId;

            Console.Write("\tDescription : ");
            string description = Console.ReadLine();

            IsEmptyValidation(ref description);
            playlist.Description = description;

            Console.Write("\tSongs ids : ");
            playlist.Songs = Console.ReadLine();

            Console.Write("\tIs public?(Yes/No?) : ");
            string isPublic = Console.ReadLine().ToLower();

            playlist.IsPublic = (isPublic == "yes" || isPublic == "y" || isPublic == "true" || isPublic == "1") ? true : false;

            _playlistRepository.Save(playlist);

            Console.WriteLine("\tPlaylist saved successfully.");
            Console.ReadKey(true);
        }