Esempio n. 1
0
        // Update Existing Content
        // Find Existing Content
        // Create an updated version
        // Pass the updated content to the repository Update method
        private void UpdateContent()
        {
            _console.WriteLine("Enter title of content you would like to update:");
            string           titleInput      = _console.ReadLine();
            StreamingContent existingContent = _streamingRepo.GetContentByTitle(titleInput);

            if (existingContent == null)
            {
                _console.WriteLine("There is no content with that Title.\n" +
                                   "Press any key to continue...");
                _console.ReadLine();
            }
            else
            {
                StreamingContent content = new StreamingContent();
                _console.WriteLine($"Current title is {existingContent.Title}\n" +
                                   $"Please enter a new title:");
                content.Title = _console.ReadLine();

                _console.WriteLine($"Current genre is {existingContent.Genre}\n" +
                                   $"Please enter a new genre:");
                content.Genre = _console.ReadLine();

                _console.WriteLine($"Current description is {existingContent.Description}\n " +
                                   $"Please enter a new description:");
                content.Description = _console.ReadLine();

                _console.WriteLine($" Current Maturity Rating is {existingContent.TypeOfMaturityRating}\n" +
                                   $"Please  select a new Maturity Rating:\n" +
                                   "1) G \n" +
                                   "2) PG \n" +
                                   "3) PG13 \n" +
                                   "4) R \n" +
                                   "5) NR \n");

                string maturityString   = _console.ReadLine();
                int    maturityratingID = int.Parse(maturityString);
                content.TypeOfMaturityRating = (MaturityRating)maturityratingID;

                _console.WriteLine($"Current Star Rating is {existingContent.StarRating}\n" +
                                   $"Please enter a new Star Rating: ");
                content.StarRating = Convert.ToInt32(_console.ReadLine());

                _console.WriteLine($"Current Streaming Quality is {existingContent.TypeOfStreamingQualityType}\n" +
                                   $"Please select a new Streaming Quality: \n" +
                                   "1) SD240 \n" +
                                   "2) SD480 \n" +
                                   "3) HD720 \n" +
                                   "4) HD1080 \n" +
                                   "5) UHD4K \n");

                string qualityInput = _console.ReadLine();
                switch (qualityInput)
                {
                case "1":
                    content.TypeOfStreamingQualityType = StreamingQualityType.SD240;
                    break;

                case "2":
                    content.TypeOfStreamingQualityType = StreamingQualityType.SD360;
                    break;

                case "3":
                    content.TypeOfStreamingQualityType = StreamingQualityType.HD720;
                    break;

                case "4":
                    content.TypeOfStreamingQualityType = StreamingQualityType.HD1080;
                    break;

                case "5":
                    content.TypeOfStreamingQualityType = StreamingQualityType.UHD4K;
                    break;
                }
                //int qualityID = int.Parse(qualityString);
                //content.TypeOfStreamingQualityType = (StreamingQualityType)qualityID;

                _console.WriteLine($"Current Language is {existingContent.TypeOfLanguage}\n" +
                                   $"Please select a new Language: \n" +
                                   "1) English \n" +
                                   "2) French \n" +
                                   "3) Chinese \n" +
                                   "4) Korean \n" +
                                   "5) Spanish \n");

                string languageInput = _console.ReadLine();
                switch (languageInput)
                {
                case "1":
                    content.TypeOfLanguage = Language.English;
                    break;

                case "2":
                    content.TypeOfLanguage = Language.French;
                    break;

                case "3":
                    content.TypeOfLanguage = Language.Chinese;
                    break;

                case "4":
                    content.TypeOfLanguage = Language.Korean;
                    break;

                case "5":
                    content.TypeOfLanguage = Language.Spanish;
                    break;
                }

                _streamingRepo.UpdateExistingContent(existingContent.Title, content);
                _console.WriteLine("Your content has been updated/\n" +
                                   "Press any key to continue...");
                _console.ReadKey();
            }
        }
Esempio n. 2
0
        // Update existing content
        // Find existing content
        // Create an updated version
        // Pass the updated content to the repository Update method
        private void UpdateExistingContent()
        {
            _console.Clear();

            _console.WriteLine("Enter the Title of the content you would like to update.");
            string           targetTitle     = _console.ReadLine();
            StreamingContent existingContent = _streamingRepository.GetContentByTitle(targetTitle);



            if (existingContent is null)
            {
                _console.WriteLine("There is no content with that Title.\n" +
                                   "Press any key to continue.");
                _console.ReadKey();
            }
            else
            {
                StreamingContent content = new StreamingContent();
                _console.WriteLine($"Current Title: {existingContent.Title}.\n" +
                                   $"Please enter a new Title");
                content.Title = _console.ReadLine();         //  Stores the user input as a string

                _console.WriteLine($"Current Descirption: {existingContent.Description}.\n" +
                                   $"Add a new Description");
                content.Description = _console.ReadLine();

                _console.WriteLine($"Current Genre: {existingContent.Genre}.\n" +
                                   $"Add a new Genre");
                content.Genre = _console.ReadLine();

                _console.WriteLine($"Current Star Rating: {existingContent.StarRating}.\n" +
                                   $"Add a new Star Rating");
                content.StarRating = Convert.ToInt32(_console.ReadLine());     // Converts the string input to an integer
                                                                               // content.StarRating = int.Parse(_console.ReadLine());    //  Does the same as the above line of code

                _console.WriteLine($"Current Maturity Rating: {existingContent.MaturityRating}. \n" +
                                   $"Add a new Maturity Rating:\n" +
                                   "1) G  \n" +
                                   "2) PG \n" +
                                   "3) PG-13 \n" +
                                   "4) R \n" +
                                   "5) NR ");

                string maturityString = _console.ReadLine();
                int    ratingID       = int.Parse(maturityString);
                content.MaturityRating = (MaturityRatingType)ratingID;

                _console.WriteLine($"Current Language: {existingContent.Language}.\n" +
                                   $"Enter the new Language:\n" +
                                   "1) English \n" +
                                   "2) Spanish \n" +
                                   "3) French \n" +
                                   "4) Japanese \n" +
                                   "5) Chinese ");
                string language   = _console.ReadLine(); // Since this property is in a enum you must convert that to a readable value for the program
                int    languageID = int.Parse(language);
                content.Language = (LanguageType)languageID;

                _console.WriteLine($"Current Streaming Quality: {existingContent.TypeOfStreamingQuality}.\n" +
                                   $"Select a new Streaming Quality: \n" +
                                   "1) SD240p \n" +
                                   "2) SD480p \n" +
                                   "3) HD720p \n" +
                                   "4) HD1080p \n" +
                                   "5) UHD4K ");
                string userInput = _console.ReadLine();
                switch (userInput)
                {
                case "1":
                    content.TypeOfStreamingQuality = (StreamingQualityType)int.Parse(userInput);
                    break;

                case "2":
                    content.TypeOfStreamingQuality = (StreamingQualityType)int.Parse(userInput);        // Both ways will work
                    break;

                case "3":
                    content.TypeOfStreamingQuality = StreamingQualityType.Hd720p;       // Both ways will work
                    break;

                case "4":
                    content.TypeOfStreamingQuality = StreamingQualityType.Hd1080p;
                    break;

                case "5":
                    content.TypeOfStreamingQuality = StreamingQualityType.UHD4k;
                    break;
                }

                _streamingRepository.UpdateExistingContent(existingContent.Title, content);
                _console.WriteLine("content has been successfully updated.\n" +
                                   "Press any key to continue.");
                _console.ReadKey();
            }
        }
Esempio n. 3
0
        private void UpdateExistingContent()

        {
            bool endUpdateContent = false;

            while (!endUpdateContent)
            {
                Console.Clear();
                string           qualityUser;
                string           maturityUser;
                StreamingQuality output;
                MaturityRating   output2;
                Console.WriteLine("Enter the title of the content you wish to update:");
                string           titleInput      = Console.ReadLine();
                StreamingContent existingContent = _streamingRepo.GetContentByTitle(titleInput);
                if (existingContent == null)
                {
                    Console.WriteLine("There is no content with that Title.\n" +
                                      "Press any key to continue");
                    Console.ReadKey();
                }
                else
                {
                    Console.Clear();
                    StreamingContent updatedContent = new StreamingContent();
                    Console.WriteLine($"The title is {existingContent.Title}, update to:\n");
                    string newTitle = Console.ReadLine();
                    updatedContent.Title = newTitle;
                    Console.Clear();
                    Console.WriteLine($"The description is {existingContent.Description}, update to:\n");
                    string newDescription = Console.ReadLine();
                    updatedContent.Description = newDescription;
                    Console.Clear();
                    Console.WriteLine($"The star rating is {existingContent.StarRating}, update to:\n");
                    updatedContent.StarRating = Convert.ToInt32(Console.ReadLine());
                    //streamingContent.StarRating = int.Parse(Console.ReadLine());
                    Console.Clear();
                    Console.WriteLine($"The genre is {existingContent.Genre}, update to:\n");
                    updatedContent.Genre = Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine($"The language is {existingContent.Language}, update to:\n");
                    updatedContent.Language = Console.ReadLine();
                    Console.Clear();
                    bool validQualityEntry = false;
                    while (!validQualityEntry)
                    {
                        Console.WriteLine($"The video quality is {existingContent.TypeOfStreamingQuality}, to update\n" +
                                          $"Select from:\n" +
                                          $"SD240\n" +
                                          $"SD480\n" +
                                          $"HD720\n" +
                                          $"HD1080\n" +
                                          $"UHD4K\n");
                        qualityUser = (Console.ReadLine()).ToUpper();
                        Console.Clear();
                        if (Enum.TryParse(qualityUser, out output))
                        {
                            updatedContent.TypeOfStreamingQuality = output;
                            validQualityEntry = true;
                        }
                        else
                        {
                            Console.WriteLine("Invalid input, try again:");
                        }
                    }
                    Console.Clear();
                    bool validMaturityEntry = false;
                    while (!validMaturityEntry)
                    {
                        Console.WriteLine($"Enter {existingContent.Title} maturity rating:\n" +
                                          $"Select From:\n" +
                                          $"G\n" +
                                          $"PG\n" +
                                          $"PG_13\n" +
                                          $"R\n" +
                                          $"NC_17");
                        maturityUser = (Console.ReadLine()).ToUpper();
                        Console.Clear();
                        if (Enum.TryParse(maturityUser, out output2))
                        {
                            updatedContent.MaturityRating = output2;
                            validMaturityEntry            = true;
                        }
                        else
                        {
                            Console.WriteLine("Invalid input, try again:");
                        }
                    }
                    bool continueToDisplay = false;
                    while (!continueToDisplay)
                    {
                        Console.Clear();
                        Console.WriteLine("Here is what you entered");
                        Console.WriteLine($"Title: {updatedContent.Title}\n" +
                                          $"Description: {updatedContent.Description}\n" +
                                          $"Stars: {updatedContent.StarRating}\n" +
                                          $"Genre: {updatedContent.Genre}\n" +
                                          $"Language: {updatedContent.Language}\n" +
                                          $"Quality: {updatedContent.TypeOfStreamingQuality}\n" +
                                          $"Maturity: {updatedContent.MaturityRating}\n" +
                                          $"Family Friendly: {updatedContent.IsFamilyFriendly}\n" +
                                          $"\n" +
                                          $"Do you wish to commit changes to the directory?\n" +
                                          $"Enter 'N' to reenter your content\n" +
                                          $"Enter 'Y' to commit changes to the directory");
                        string continueYN = (Console.ReadLine()).ToUpper();
                        if (continueYN == "Y")
                        {
                            _streamingRepo.UpdateExistingContent(existingContent.Title, updatedContent);
                            endUpdateContent  = true;
                            continueToDisplay = true;
                        }
                        else if (continueYN == "N")
                        {
                            continueToDisplay = true;
                        }
                        else
                        {
                            Console.WriteLine("Invalid input, try again.");
                        }
                    }
                }
            }
        }