Exemplo n.º 1
0
        private void RemoveContent()
        {
            Console.WriteLine("Which item would you like to remove? ");
            List <StreamingContent> contentList = _streamingRepo.GetContents();
            int count = 0;

            foreach (StreamingContent content in contentList)
            {
                count++;
                Console.WriteLine($"{count}. {content.Title}");
            }
            int targetContentId = int.Parse(Console.ReadLine());
            int targetIndex     = targetContentId - 1; // to offset count++

            if (targetIndex >= 0 && targetIndex < contentList.Count)
            {
                StreamingContent desiredContent = contentList[targetIndex];
                if (_streamingRepo.DeleteContent(desiredContent))
                {
                    Console.WriteLine($"Deleted {desiredContent.Title}");
                }
                else
                {
                    Console.WriteLine($"an error occurred and {desiredContent.Title} was not removed");
                }
            }
            else
            {
                Console.WriteLine("No content has that ID");
            }
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }