public static void DeleteMovie() { int movId; bool notANum; List <Movie> movies; do { Console.Write("Which movie would you like to delete?\n"); movies = MovieManager.MovieList(""); int i = 0; foreach (Movie movie in movies) { i++; Console.WriteLine(i + ") " + movie.Title); } notANum = false; Console.Write("Input: "); if (!int.TryParse(Console.ReadLine(), out movId)) { Console.WriteLine("Invalid input"); Console.ReadKey(); notANum = true; } Console.Clear(); } while (notANum); int delMov = movies[movId - 1].ID; Console.Write("Are you sure you want to delete " + movies[movId - 1].Title + "? \n1) Yes \n2) No \nInput: "); if (!int.TryParse(Console.ReadLine(), out int sure)) { Console.WriteLine("Invalid input"); Console.ReadKey(); notANum = true; } if (sure == 1) { MovieManager.DeleteMovie(movies[movId - 1]); Console.Write("Movie has been deleted"); Console.ReadKey(); Console.Clear(); } else { Console.WriteLine("Deletion has been cancelled"); Console.ReadKey(); Console.Clear(); } }
public static void SearchMovie() { Console.Write("Movie search: "); string searchMov = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nList of Movies"); Console.ResetColor(); List <Movie> movie = MovieManager.MovieList(searchMov); foreach (Movie item in movie) { Console.WriteLine("Movie title: " + item.Title + "\nRelease Year: " + item.ReleaseYear + "\nDescription: '" + item.Description + "'\n\n"); } if (movie.Count == 0) { Console.WriteLine("\nNo result related to '" + searchMov + "'\nTry something else.\n"); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); Console.Clear(); }
public static void UpdateMovie() { int movId; bool notANum; List <Movie> movies; do { Console.Write("Which movie would you like to edit?\n"); movies = MovieManager.MovieList(""); int i = 0; foreach (Movie movie in movies) { i++; Console.WriteLine(i + ") " + movie.Title); } notANum = false; Console.Write("Input: "); if (!int.TryParse(Console.ReadLine(), out movId)) { Console.WriteLine("Invalid input"); Console.ReadKey(); notANum = true; } Console.Clear(); } while (notANum); int updMov = movies[movId - 1].ID; Console.Clear(); Console.Write("Title: "); string title = Console.ReadLine(); Console.Clear(); int releaseYear; bool noNum; do { noNum = false; Console.Write("Release year: "); if (!int.TryParse(Console.ReadLine(), out releaseYear)) { Console.WriteLine("Invalid input"); Console.ReadKey(); noNum = true; } Console.Clear(); } while (noNum); Console.Write("Description: "); string des = Console.ReadLine(); Console.Clear(); MovieManager.UpdateMovie(new Movie(updMov, title, releaseYear, des)); Console.WriteLine("Movie has now been updated"); Console.ReadKey(); Console.Clear(); }