private void SeedContentList() { StreamingContent movieOne = new StreamingContent("Spirited Away", "test", MaturityRating.PG, 5, GenreType.Anime); StreamingContent movieTwo = new StreamingContent("2001", "test", MaturityRating.PG_13, 5, GenreType.SciFi); StreamingContent movieThree = new StreamingContent("A Clockwork Orange", "test", MaturityRating.R, 4, GenreType.Thriller); //This is posting them to the our _streamingRepo directory (fake database) _streamingRepo.AddContentToDirectory(movieOne); _streamingRepo.AddContentToDirectory(movieTwo); _streamingRepo.AddContentToDirectory(movieThree); }
private void SeedContent() { StreamingContent toyStory = new StreamingContent("Bromance", "Toy Story", 10, StreamingQualityType.HD1080, "A good movie", Language.English, MaturityRating.G); _streamingRepo.AddContentToDirectory(toyStory); Movie rubber = new Movie("Drama", "Rubber", 6, StreamingQualityType.HD1080, "Mind Murder", Language.French, MaturityRating.R, 97.5); _streamingRepo.AddContentToDirectory(rubber); Show avatar = new Show("Action", "Avatar", 8, StreamingQualityType.HD720, "The Last Airbender", Language.English, MaturityRating.PG, new List <Episode>()); _streamingRepo.AddContentToDirectory(avatar); }
public void StreamingContentNotes() { StreamingContent baseObject = new StreamingContent(); Movie movieObject = new Movie(); Show tvShow = new Show(); Episode episodeOfTvShow = new Episode(); tvShow.Episodes.Add(episodeOfTvShow); Movie venom = new Movie("Venom", "The best romance movie of our age", 9005, MaturityRating.PG_13, GenreType.Bromance, 132); StreamingRepository repo = new StreamingRepository(); repo.AddContentToDirectory(tvShow); }
private void CreateNewContent() { //a new content object StreamingContent content = new StreamingContent(); //ask user for information //Title _console.WriteLine("Please enter the title of the new content: "); content.Title = _console.ReadLine(); //Description _console.WriteLine($"Please enter a description for {content.Title}"); content.Description = _console.ReadLine(); //StarRating _console.WriteLine($"Please enter the star rating for {content.Title}"); content.StarRating = float.Parse(_console.ReadLine()); //MatuirityRating _console.WriteLine("Select a Maturity Rating: \n" + "1)G \n" + "2)PG \n" + "3)PG 12 \n" + "4)R \n" + "5)NC 17 \n" + "6)MA \n"); string maturityResponse = _console.ReadLine(); switch (maturityResponse) { case "1": content.MaturityRatin = MaturityRating.G; break; case "2": content.MaturityRatin = MaturityRating.PG; break; case "3": content.MaturityRatin = MaturityRating.PG_13; break; case "4": content.MaturityRatin = MaturityRating.R; RemoveContentFromList(); break; case "5": content.MaturityRatin = MaturityRating.NC_17; break; case "6": content.MaturityRatin = MaturityRating.MA; break; } //TypeOfGenre _console.WriteLine("Select a genre: \n" + "1) Horror \n" + "2)RomCom \n" + "3)Fantasy \n" + "4)Sci-Fi \n" + "5)Drama \n" + "6)Bromance \n" + "7)Action \n" + "8)Documentary \n" + "9)Thriller \n"); string genResponse = _console.ReadLine(); int genreID = int.Parse(genResponse); content.TypeOfGenre = (GenreType)genreID; //a new content with properties filled out by user //pass that to the add emthod in our repo _streamingRepo.AddContentToDirectory(content); }
// Access to streaming repo/the Add Method // Prompt the user // Take in content from the console // Actually add the contrent through the Add Method private void AddNewStreamingContent() { _console.Clear(); StreamingContent content = new StreamingContent(); _console.WriteLine("Please enter a Title"); content.Title = _console.ReadLine(); // Stores the user input as a string _console.WriteLine("Add a Description"); content.Description = _console.ReadLine(); _console.WriteLine("Add the Genre"); content.Genre = _console.ReadLine(); _console.WriteLine("Add a 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("Add a 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("Enter the 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("Select a 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.AddContentToDirectory(content); _console.WriteLine("Your content has been added.\n" + "Press any key to return to the main menu."); _console.ReadKey(); }
private void CreateNewContent() { _console.Clear(); StreamingContent content = new StreamingContent(); // title _console.WriteLine("Please enter the title of the content: "); content.Title = _console.ReadLine(); // description _console.WriteLine("Please enter the description: "); content.Description = _console.ReadLine(); // MaturityRating _console.WriteLine("Select a Maturity Rating: \n" + "1) G\n" + "2) PG \n" + "3) PG-13 \n" + "4) R \n" + "5) NC-17 \n" + "6) TV-MA" ); string maturityString = _console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } // StarRating _console.WriteLine("Please enter the star-rating (1-5): "); content.StarRating = int.Parse(_console.ReadLine()); // int.Parse converts a string to an integer // type of genre _console.WriteLine("Select a Genre: \n" + "1) Horror \n" + "2) SciFi \n" + "3) Drama \n" + "4) Action \n" + "5) Comedy \n" + "6) Anime \n" + "7) Documentary \n" + "8) Thriller \n" + "9) Romance" ); string genreInput = _console.ReadLine(); int genreID = int.Parse(genreInput); content.TypeOfGenre = (GenreType)genreID; // casting : what you want to be is inside the parantheses and what you are starting with is to the right _streamingRepo.AddContentToDirectory(content); }
private void CreateNewContent() { _console.Clear(); // clears all the content from the menu end goal of method is to create an new content StreamingContent content = new StreamingContent(); //new instance of class StreamingContent named content //title _console.WriteLine("Please enter the title of the content:"); content.Title = _console.ReadLine(); //sets the title of the streaming object to whatever the user inputs //description _console.WriteLine("Please enter the description:"); content.Description = _console.ReadLine(); // sets the description of the streaming object to whatever the user inputs //maturityRating _console.WriteLine("Select a Maturity Rating: \n" + "1) G \n" + "2) PG \n" + "3) PG13 \n" + "4) R \n" + "5) NC17 \n" + "6) TV MA"); string maturityString = _console.ReadLine(); // takes in the string then uses the string in a switch statement to set the streaming object maurityrating switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; // the streaming objects maturity rating will be equal to the MaturityRating.G break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } //star rating _console.WriteLine("Please enter the star rating 1-100"); double rating = Convert.ToDouble(_console.ReadLine()); // convert could handle a null were parse couldnt handle a null //double rating2 = double.Parse(_console.ReadLine()); // like casting parese the string in a double. //genre _console.WriteLine("Select a Genre \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4: Action \n" + "5: Comedy \n" + "6: Ainme \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); // must be in same order as enum string genreInput = _console.ReadLine(); int genreID = int.Parse(genreInput); content.TypeOfGenre = (GenreType)genreID; // we are taking an integer and casting into a enum Casting is taking one type and changing into another type We are taking something and changing it from it state what type you want it to be goes inside the paranthese and what it is currently goes outside and to the right _streamingRepo.AddContentToDirectory(content); // the streamingresporitory inherited from the streaming content repository thus we have the ability to use the method AddContentToDiretory and used the StreamingContent named content which is a local variable since we created and new instance/object of the type StreamingContent }
private void CreateNewContent() { // a new content object StreamingContent content = new StreamingContent(); //Title Console.Clear(); Console.WriteLine("Please enter a title"); content.Title = Console.ReadLine(); Console.Clear(); //Description (string) Console.WriteLine($"Please enter a description for {content.Title}"); content.Description = Console.ReadLine(); Console.Clear(); //Star Rating (float) chooseStarRating: Console.WriteLine($"Please enter the star rating for {content.Title}"); try { content.StarRating = float.Parse(Console.ReadLine()); } catch (Exception) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 5.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseStarRating; } if (content.StarRating > 5) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 5.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseStarRating; } Console.Clear(); chooseMaturityRating: //Maturity Rating (MaturityRating) Console.WriteLine($"Please select the maturity rating for {content.Title}\n" + "1) G \n" + "2) PG \n" + "3) PG-13 \n" + "4) R \n" + "5) NC 17"); int MaturityResponse; try { MaturityResponse = int.Parse(Console.ReadLine()); } catch (Exception) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 5.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseMaturityRating; } if (MaturityResponse > 5) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 5.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseMaturityRating; } switch (MaturityResponse) { case 1: content.MRating = MaturityRating.G; break; case 2: content.MRating = MaturityRating.PG; break; case 3: content.MRating = MaturityRating.PG_13; break; case 4: content.MRating = MaturityRating.R; break; case 5: content.MRating = MaturityRating.NC_17; break; } //TypeOfGenre chooseGenre: Console.Clear(); Console.WriteLine("Select a genre: \n" + "1) Horror\n" + "2) RomCom \n" + "3) Fantasy \n" + "4) Sci-Fi\n" + "5) Drama\n" + "6) Bromance\n" + "7) Action \n" + "8) Documentary \n" + "9) Thriller"); int genreResponse; try { genreResponse = int.Parse(Console.ReadLine()); } catch (Exception) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 9.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseGenre; } if (genreResponse > 10) { Console.Clear(); Console.WriteLine("Please enter a valid number between 1 and 9.\n" + "Press any key to continue"); Console.ReadKey(); Console.Clear(); goto chooseGenre; } content.TypeOfGenre = (GenreType)genreResponse; //a new content with properties filled out by user //Pass that to the add method in our repo _streamingRepo.AddContentToDirectory(content); Console.Clear(); Console.WriteLine($"You have successfully added the streaming content, {content.Title}\n" + "Press any key to continue"); Console.ReadKey(); }
private void CreateNewContent() { _console.Clear(); StreamingContent content = new StreamingContent(); //ref to 07_ // title _console.WriteLine("Please enter the title of the content: "); content.Title = _console.ReadLine(); //readline always returns a string //decription _console.WriteLine("Please enter the description of the content: "); content.Description = _console.ReadLine(); //Maturity rating _console.WriteLine("Please Select a Maturity Rating: \n" + "1) G \n" + "2) PG \n" + "3) PG-13 \n" + "4) R \n" + "5) NC-17 \n" + "6) TV-MA"); string maturityString = _console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } //star rating --int-- _console.WriteLine("Please enter the star rating (1-5): "); content.StarRating = int.Parse(_console.ReadLine()); //parse is similar to casting turns string to int // type of genre _console.WriteLine("Please enter the Maturity Rating of the content: "); //remember enum _console.WriteLine("Select a Genre: \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4: Action \n" + "5: Comedy \n" + "6: Anime \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); string genreInput = _console.ReadLine(); //this works in leiu of the switch case int genreID = int.Parse(genreInput); content.TypeOfGenre = (GenreType)genreID; //<--casting taking an int and casting to an enum _streamingRepo.AddContentToDirectory(content); //now this a part of the content directory }
private void CreateNewContent() { Console.Clear(); StreamingContent content = new StreamingContent(); // title Console.WriteLine("Please enter the title of the content: "); content.Title = Console.ReadLine(); //description Console.WriteLine("Please enter the description: "); content.Description = Console.ReadLine(); //MRating Console.WriteLine("Select a Maturity Rating: \n" + "1) G \n" + "2) PG \n" + "3) PG 13 \n" + "4) R \n" + "5) NC 17 \n" + "6) TV MA"); string maturityString = Console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } //star rating Console.WriteLine("Please enter the star-rating (1-5): "); content.StarRating = int.Parse(Console.ReadLine()); //type of genre Console.WriteLine("Select a Genre: \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4: Action \n" + "5: Comedy \n" + "6: Anime \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); string genreInput = Console.ReadLine(); int genreID = int.Parse(genreInput); content.TypeOfGenre = (GenreType)genreID; _streamingRepo.AddContentToDirectory(content); }
private void CreateNewContent() { _console.Clear(); StreamingContent content = new StreamingContent(); //title _console.WriteLine("Please enter the title of the content: "); content.Title = _console.ReadLine(); //description _console.WriteLine("Please enter the description: "); content.Description = _console.ReadLine(); //MRating _console.WriteLine("Select a Maturity Rating: \n" + //see different way of handling enums for type of genre "1) G \n" + "2) PG \n" + "3) PG-13 \n" + "4) R \n" + "5) NC 17 \n" + "6) TV MA"); string maturityString = _console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG - 13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } //star rating _console.WriteLine("Please enter the star-rating (1-5): "); content.StarRating = int.Parse(_console.ReadLine()); // you could use Convert.Int32 in place of int.Parse //type of genre _console.WriteLine("Select a Genre \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4: Action \n" + "5: Comedy \n" + "6: Anime \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); string genreInput = _console.ReadLine(); int genreID = int.Parse(genreInput); //parsing string to int content.TypeOfGenre = (GenreType)genreID; //casting int to enum _streamingRepo.AddContentToDirectory(content); }
} // RunMenu method private void CreateNewContent() { _console.Clear(); StreamingContent content = new StreamingContent(); // title _console.WriteLine("Please enter the title of the content: "); content.Title = _console.ReadLine(); // description _console.WriteLine("Please enter the description: "); content.Description = _console.ReadLine(); // maturity rating _console.WriteLine("Select a Maturity Rating: \n" + "1) G \n" + "2) PG \n" + "3) PG 13 \n" + "4) R \n" + "5) NC 17 \n" + "6) TN MA"); string maturityString = _console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } // star rating _console.WriteLine("Please enter the star-rating (1 - 5): "); content.StarRating = Convert.ToInt32(_console.ReadLine()); // or int.Parse(_console.Readline()) // type of genre // ** prompts MUST be in the same order as the enum _console.WriteLine("Select a Genre: \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4: Action \n" + "5: Comedy \n" + "6: Anime \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); string genreInput = _console.ReadLine(); // the number input is a string int genreID = int.Parse(genreInput); // convert the inputted string to an integer content.TypeOfGenre = (GenreType)genreID; // re-cast the int genreID to GenreType (the type of the genre enum as defined in StreamingContent.cs // title, description, maturity rating, star rating, type of genre // (don't receive isFamilyFriendly from user; it's generated based on maturity rating) _streamingRepo.AddContentToDirectory(content); } // CreateNewContent method
//Access to streaming repo/the add method //Prompt the user //Take in content //Actually add the content through our add method private void AddNewStreamingContent() { StreamingContent content = new StreamingContent(); Console.WriteLine("Hello there, please enter a title"); content.Title = Console.ReadLine(); Console.WriteLine("Now, add a description"); content.Description = Console.ReadLine(); Console.WriteLine("What is the genre"); content.Genre = Console.ReadLine(); Console.WriteLine("What is the star rating?"); content.StarRating = Convert.ToInt32(Console.ReadLine()); //content.StarRating = int.Parse(Console.ReadLine()); Console.WriteLine("Select a Maturity rating (enter a value between 1 and 5)\n" + "1) G \n" + "2) PG \n" + "3) PG 13 \n" + "4) R \n" + "5) NC 17"); string maturityString = Console.ReadLine(); int ratingID = int.Parse(maturityString); content.MaturityRating = (MaturityRating)ratingID; Console.WriteLine("Select a streaming Quality from below (choose a value between 1 and 5 \n" + "1) SD240 \n" + "2) SD480 \n" + "3) HD720 \n" + "4) HD1080 \n" + "5) UHD4k"); string userInput = Console.ReadLine(); switch (userInput) { case "1": content.TypeOfStreamingQuality = StreamingQualityType.SD240; break; case "2": content.TypeOfStreamingQuality = StreamingQualityType.SD480; break; case "3": content.TypeOfStreamingQuality = StreamingQualityType.HD720; break; case "4": content.TypeOfStreamingQuality = StreamingQualityType.HD1080; break; case "5": content.TypeOfStreamingQuality = StreamingQualityType.UHD4K; break; } Console.WriteLine("Last step! What language is this content"); content.Language = Console.ReadLine(); _streamingRepo.AddContentToDirectory(content); Console.WriteLine("Your content has been added! Press any key to return to the main menu"); Console.ReadKey(); }
private void AddNewStreamingContent() { bool endAddNewContent = false; while (!endAddNewContent) { Console.Clear(); { StreamingContent streamingContent = new StreamingContent(); string qualityUser; string maturityUser; StreamingQuality output; MaturityRating output2; Console.WriteLine("Enter new streaming content title:\n"); streamingContent.Title = Console.ReadLine(); Console.Clear(); Console.WriteLine($"Enter {streamingContent.Title} description:\n"); streamingContent.Description = Console.ReadLine(); Console.Clear(); Console.WriteLine($"Enter {streamingContent.Title} star rating:\n"); streamingContent.StarRating = Convert.ToInt32(Console.ReadLine()); //streamingContent.StarRating = int.Parse(Console.ReadLine()); Console.Clear(); Console.WriteLine($"Enter {streamingContent.Title} genre:\n"); streamingContent.Genre = Console.ReadLine(); Console.Clear(); Console.WriteLine($"Enter {streamingContent.Title} language:\n"); streamingContent.Language = Console.ReadLine(); Console.Clear(); bool validQualityEntry = false; while (!validQualityEntry) { Console.WriteLine($"Enter {streamingContent.Title} quality.\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)) { streamingContent.TypeOfStreamingQuality = output; validQualityEntry = true; } else { Console.WriteLine("Invalid input, try again:"); } } Console.Clear(); bool validMaturityEntry = false; while (!validMaturityEntry) { Console.WriteLine($"Enter {streamingContent.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)) { streamingContent.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: {streamingContent.Title}\n" + $"Description: {streamingContent.Description}\n" + $"Stars: {streamingContent.StarRating}\n" + $"Genre: {streamingContent.Genre}\n" + $"Language: {streamingContent.Language}\n" + $"Quality: {streamingContent.TypeOfStreamingQuality}\n" + $"Maturity: {streamingContent.MaturityRating}\n" + $"Family Friendly: {streamingContent.IsFamilyFriendly}\n" + $"\n" + $"Do you wish to add {streamingContent.Title} to the directory?\n" + $"Enter 'N' to reenter your content\n" + $"Enter 'Y' to add {streamingContent.Title} to the directory"); string continueYN = (Console.ReadLine()).ToUpper(); if (continueYN == "Y") { _streamingRepo.AddContentToDirectory(streamingContent); endAddNewContent = true; continueToDisplay = true; } else if (continueYN == "N") { continueToDisplay = true; } else { Console.WriteLine("Invalid input, try again."); } } } } Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
private void CreateNewContent() { Console.Clear(); StreamingContent content = new StreamingContent(); // title Console.WriteLine("Please enter the title of the content: "); content.Title = Console.ReadLine(); // description Console.WriteLine("\nPlease enter the description: "); content.Description = Console.ReadLine(); // maturity rating // this is one way to do this; we'll use another way for genre Console.WriteLine("\nSelect a maturity rating: \n" + "1. G \n" + "2. PG \n" + "3. PG 13 \n" + "4. R \n" + "5. NC 17 \n" + "6. TV MA"); string matString = Console.ReadLine(); switch (matString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } // star rating Console.WriteLine("\nPlease enter the star rating (1-5): "); content.StarRating = int.Parse(Console.ReadLine()); // genre Console.WriteLine("\nSelect a Genre:\n" + // need to be in the same order as the enum "1. Horror \n" + "2. Science Fiction\n" + "3. Drama \n" + "4. Action \n" + "5. Comedy \n" + "6. Anime \n" + "7. Documentary \n" + "8. Romance \n" + "9. Thriller \n" + "10. Mystery"); string genreInput = Console.ReadLine(); int genreID = int.Parse(genreInput); content.TypeOfGenre = (GenreType)genreID; // casting // now add it to the repository _streamingRepo.AddContentToDirectory(content); }
private void CreateNewContent() { _console.Clear(); StreamingContent content = new StreamingContent(); // title _console.WriteLine("Please enter the title of the content: "); content.Title = _console.ReadLine(); // description _console.WriteLine("Please enter the description: "); content.Description = _console.ReadLine(); // MRating _console.WriteLine("Select a Maturity Reading: \n" + "1) G \n" + "2) PG \n" + "3) PG_13 \n" + "4) R \n" + "5) NC_17 \n" + "6) TV_MA"); string maturityString = _console.ReadLine(); switch (maturityString) { case "1": content.MaturityRating = MaturityRating.G; break; case "2": content.MaturityRating = MaturityRating.PG; break; case "3": content.MaturityRating = MaturityRating.PG_13; break; case "4": content.MaturityRating = MaturityRating.R; break; case "5": content.MaturityRating = MaturityRating.NC_17; break; case "6": content.MaturityRating = MaturityRating.TV_MA; break; } // Star Rating _console.WriteLine("Please enter the star-rating (1-5): "); content.StarRating = int.Parse(_console.ReadLine()); // content.StarRatine = Convert.ToInt32(_console.ReadLine()); - would do the same thing // type of genre // need to be in same order as enum - uses the index or number of element in enum _console.WriteLine("Select a Genre: \n" + "1: Horror \n" + "2: Sci-Fi \n" + "3: Drama \n" + "4. Action \n" + "5: Comedy \n" + "6: Anime \n" + "7: Documentary \n" + "8: Thriller \n" + "9: Romance"); string genreInput = _console.ReadLine(); // read line always returns a string int genreID = int.Parse(genreInput); // this is called casting content.TypeOfGenre = (GenreType)genreID; // AddContentToDirectory - method, content is variable // _stramingRepo is a field because we want it to be accessed through all methods _streamingRepo.AddContentToDirectory(content); }