private static void UserListInteraction(List <Movie> movies, string fileName) { Console.Clear(); Console.WriteLine($"File Loaded: {fileName}.json\r\n\r\n"); Console.WriteLine(DisplayMovieInfo(movies)); Console.WriteLine("\r\nType \"S\" to save movie to a different file, type \"C\" to Copy list to another file, type \"D\" to Delete movie from list, or type \"R\" to Reload streaming providers for a result.\r\nType \"F\" to find a new movie or show, type \"L\" to load another file.\r\nType \"Q\" to quit."); var menuChoice = Console.ReadLine().ToUpper().Trim(); while (menuChoice != "S" && menuChoice != "C" && menuChoice != "D" && menuChoice != "R" && menuChoice != "F" && menuChoice != "L" && menuChoice != "Q") { Console.WriteLine("Please enter S (Save movie to different file), C (Copy list to another list), D (Delete a movie), R (Reload providers), F (Find a movie), L (Load a file), or Q (Quit)"); menuChoice = Console.ReadLine().ToUpper().Trim(); } switch (menuChoice) { case "S": int i = UserPicksArray(); while (i >= movies.Count || i < 0) { Console.WriteLine("Selection is out of range, please pick again"); i = UserPicksArray(); } UserSaveMovie(movies[i]); Console.WriteLine("List may need to be reloaded. Press any key to continue"); Console.ReadKey(); UserListInteraction(movies, fileName); break; case "C": UserSaveList(movies); Console.WriteLine("Press any key to continue"); Console.ReadKey(); UserListInteraction(movies, fileName); break; case "D": i = UserPicksArray(); while (i >= movies.Count || i < 0) { Console.WriteLine("Selection is out of range, please pick again"); i = UserPicksArray(); } movies.RemoveAt(i); MovieInteraction.SaveMoviesToList(movies, fileName + _extension); Console.WriteLine("Press any key to continue"); Console.ReadKey(); UserListInteraction(movies, fileName); break; case "R": i = UserPicksArray(); while (i >= movies.Count || i < 0) { Console.WriteLine("Selection is out of range, please pick again"); i = UserPicksArray(); } var results = WebInteraction.SearchUtellyById(movies[i].ImdbId); movies[i].Locations = results.collection.Locations; MovieInteraction.SaveMoviesToList(movies, fileName + _extension); Console.WriteLine("Press any key to continue"); Console.ReadKey(); UserListInteraction(movies, fileName); break; case "F": MainSearch(); break; case "L": UserLoadMovieList(); break; case "Q": break; } }
// TODO: Allow user to save result from OMDB list before Utelly search? private static List <Movie> ShowAndPickOmdbSearch(List <Movie> movies) { Movie selectedMovie = null; // Display results and ask for user to select one Console.WriteLine(DisplayMovieInfo(movies)); if (movies.Count != 0 && movies[0].Title != null) { int userSelection; userSelection = UserPicksArray(); while (userSelection >= movies.Count || userSelection < 0) { Console.WriteLine("Selection is out of range, please pick again"); userSelection = UserPicksArray(); } selectedMovie = movies[userSelection]; // Search for streaming providers for selection using Utelly var utellyResult = WebInteraction.SearchUtellyById(selectedMovie.ImdbId); // Put streaming locations on our selected movie object selectedMovie.Locations = utellyResult.collection.Locations; //Can we search by ID? If not here we go: // var utellyResult = WebInteraction.SearchUtelly(selectedMovie.Title); // selectedMovie.Locations = utellyResult[0].Locations; Console.Clear(); Console.WriteLine($"Here are your results for {selectedMovie.Title}:\r\n\r\n"); Console.WriteLine(DisplayStreamingLocations(selectedMovie)); } // Search again, save results to file, return to results, or exit? Console.WriteLine("\r\nType \"F\" to find another movie or show, type \"S\" to save result to a list file, type \"L\" to load a previous list.\r\nType \"R\" to return to results, and type \"Q\" to quit."); var menuChoice = Console.ReadLine().ToUpper().Trim(); while (menuChoice != "F" && menuChoice != "S" && menuChoice != "L" && menuChoice != "R" && menuChoice != "Q") { Console.WriteLine("Please enter F (Find another), S (Save result to a list), L (Load list from file), R (Return to results), or Q (quit)"); menuChoice = Console.ReadLine().ToUpper().Trim(); } switch (menuChoice) { case "F": MainSearch(); break; case "S": UserSaveMovie(selectedMovie); Console.WriteLine("Press any key to go back to main menu"); Console.ReadKey(); MainMenu(); break; case "L": UserLoadMovieList(); break; case "R": Console.Clear(); ShowAndPickOmdbSearch(movies); break; case "Q": break; } return(movies); }