コード例 #1
0
 //This  method check the functionality to remove a movie from favorites
 public static void TestRemoveFavoriteMovie(FavoritesDaoCollection favoritesDao)
 {
     try
     {
         Console.Write("Enter User ID: ");
         long      userId         = long.Parse(Console.ReadLine());
         Favorites favoriteMovies = favoritesDao.GetAllFavoriteMovies(userId);
         Console.WriteLine("\n" + heading);
         foreach (MovieItem movie in favoriteMovies.MovieItemList)
         {
             Console.WriteLine(movie);
         }
         Console.Write("Enter Movie ID to remove from user favorites: ");
         long movieId = long.Parse(Console.ReadLine());
         favoritesDao.RemoveFavoriteMovie(userId, movieId);
         favoriteMovies = favoritesDao.GetAllFavoriteMovies(userId);
         Console.WriteLine("\n" + heading);
         foreach (MovieItem movie in favoriteMovies.MovieItemList)
         {
             Console.WriteLine(movie);
         }
         Console.WriteLine();
         throw new FavoritesEmptyException();
     }
     catch (FavoritesEmptyException e)
     {
         Console.WriteLine("\n" + e.Message + "\n");
     }
 }
コード例 #2
0
        //This  method check the functionality to add a movie to favorites
        public static void TestAddFavoriteMovie(FavoritesDaoCollection favoritesDao)
        {
            Console.Write("Enter User ID: ");
            long userId = long.Parse(Console.ReadLine());

            Console.Write("Enter Movie ID to add to user favorites: ");
            long movieId = long.Parse(Console.ReadLine());

            favoritesDao.AddFavoriteMovie(userId, movieId);
            Favorites favoriteMovies = favoritesDao.GetAllFavoriteMovies(userId);

            Console.WriteLine("\nAfter adding entered movie in favorites...\n\n" + heading);
            foreach (MovieItem movie in favoriteMovies.MovieItemList)
            {
                Console.WriteLine(movie);
            }
            Console.WriteLine();
        }
コード例 #3
0
        public FavoritesDaoCollectionTest()
        {
            MovieItemDaoCollection movieItemDao  = new MovieItemDaoCollection();
            List <MovieItem>       movieItemList = movieItemDao.GetMovieItemListAdmin();

            Console.WriteLine("Available Items:\n" + heading);
            foreach (MovieItem item in movieItemList)
            {
                Console.WriteLine(item);
            }
            string choice;
            FavoritesDaoCollection favoritesDao = new FavoritesDaoCollection();

            Console.WriteLine();
            l1 : Console.Write("1. Add To Favorite\n2. Remove Favorite Movie\n3. Get All Favorite Movies\n\nEnter your choice: ");
            choice = Console.ReadLine();
            switch (choice)
            {
            case "1":
            {
                TestAddFavoriteMovie(favoritesDao);
                goto l1;
            }

            case "2":
            {
                TestRemoveFavoriteMovie(favoritesDao);
                goto l1;
            }

            case "3":
            {
                TestGetAllFavoriteMovies(favoritesDao);
                goto l1;
            }

            default:
            {
                Console.WriteLine("Exiting...");
                break;
            }
            }
            Console.WriteLine();
        }