Пример #1
0
        public void MemberDisplayAllMovies()
        {
            List <Movie> movieList = movieCollection.Tree.Traverse();

            if (movieList.Count == 0)
            {
                ErrorView.Error("There are no movies yet.");
            }

            Console.Clear();
            Console.Write("==========List of Movies==========\n" +
                          "Here are the movies on file.\n\n");

            for (int i = 0; i < movieList.Count; i++)
            {
                Console.WriteLine(i + 1 + ". " + movieList[i].Title +
                                  "\n Starring: " + String.Join(",", movieList[i].Starring) +
                                  "\n Director: " + movieList[i].Director +
                                  "\n Duration: " + movieList[i].Duration + " mins" +
                                  "\n Genre: " + movieList[i].Genre.ToString() +
                                  "\n Classification: " + movieList[i].Classification.ToString() +
                                  "\n Release Date: " + movieList[i].ReleaseDate.ToString("dd/MM/yyyy") +
                                  "\n Copies:" + movieList[i].CopiesAvailable + "\n\n");
            }

            Console.Write("\nPress any key to return to the main menu.");
            Console.ReadKey();
        }
Пример #2
0
        public void StaffMainMenu()
        {
            Console.Clear();
            Console.Write("==========Staff Menu==========\n" +
                          " 1. Add a new movie DVD\n" +
                          " 2. Remove a movie DVD\n" +
                          " 3. Register a new Member\n" +
                          " 4. Find a registered member's phone number\n" +
                          " 0. Return to main menu\n" +
                          "==============================\n\n" +
                          "Please make a selection (1-4, or 0 to return to main menu): ");

            string menuChoice = Console.ReadLine();

            try
            {
                int result = Int32.Parse(menuChoice);
                switch (result)
                {
                case 1:
                    this.StaffAddMovie();
                    break;

                case 2:
                    this.StaffRemoveMovie();
                    break;

                case 3:
                    this.StaffAddMember();
                    break;

                case 4:
                    this.StaffFindMember();
                    break;

                case 0:
                    this.MainMenu();
                    break;

                default:
                    ErrorView.Error("Invalid selection. Please choose 1, 2, 3, 4 or 0.");
                    break;
                }
            }
            catch (Exception e)
            {
                if (e is FormatException)
                {
                    ErrorView.Error("Invalid selection. Please choose 1, 2, 3, 4 or 0.");
                }
                else
                {
                    ErrorView.Error(e.Message);
                }
            }
            StaffMainMenu();
        }
Пример #3
0
        public void MemberBorrowMovie(Member member)
        {
            Console.Clear();
            Console.Write("==========Borrow Movie==========\n" +
                          "Movie Name: ");
            string movieName = Console.ReadLine();

            try
            {
                Console.Clear();
                Console.Write("Please wait...");
                Movie result = movieCollection.Tree.Search(movieName);

                bool reviewValidInput = false;
                while (!reviewValidInput)
                {
                    Console.Clear();
                    Console.Write("==========Borrow Movie==========\n" +
                                  "Please review the below information to ensure everything is correct.\n" +
                                  "\n Title: " + result.Title +
                                  "\n Starring: " + String.Join(",", result.Starring) +
                                  "\n Director: " + result.Director +
                                  "\n Duration: " + result.Duration + " mins" +
                                  "\n Genre: " + result.Genre.ToString() +
                                  "\n Classification: " + result.Classification.ToString() +
                                  "\n Release Date: " + result.ReleaseDate.ToString("dd/MM/yyyy") +
                                  "\n\nTo confirm borrowing this movie, press Y. To start again, press N.");
                    string reviewChoice = Console.ReadLine();

                    switch (reviewChoice.ToLower())
                    {
                    case "y":
                        Console.Clear();
                        Console.Write("Please wait...");
                        if (member.RentedMovies.Count >= 10)
                        {
                            throw new Exception("You have reached your quota of borrowed movies. " +
                                                "Please return some movies before attempting to borrow more.");
                        }
                        movieCollection.Tree.BorrowMovie(result);
                        member.RentedMovies.Add(result);
                        return;

                    case "n":
                        return;
                    }

                    // no need for default as it will loop again if invalid response
                    Console.Beep();
                }
            }
            catch (Exception e)
            {
                ErrorView.Error(e);
            }
        }
Пример #4
0
        public void MemberReturnMovie(Member member)
        {
            if (member.RentedMovies.Count == 0)
            {
                ErrorView.Error("You have no movies to return.");
            }
            else
            {
                Console.Clear();
                Console.Write("==========Return Movie==========\n" +
                              "Here are your currently borrowed movies. Please select the one you wish to return or type 0 to exit.\n\n");

                for (int i = 0; i < member.RentedMovies.Count; i++)
                {
                    Console.WriteLine(i + 1 + ". " + member.RentedMovies[i].Title);
                }

                Movie returnChoice           = null;
                int   choice                 = 0;
                bool  returnChoiceValidInput = false;

                while (!returnChoiceValidInput)
                {
                    string choiceInput      = Console.ReadLine();
                    bool   choiceValidParse = Int32.TryParse(choiceInput, out choice);

                    if (choiceValidParse)
                    {
                        returnChoiceValidInput = true;
                        if (choice == 0)
                        {
                            return;
                        }
                        if (choice <= member.RentedMovies.Count)
                        {
                            returnChoice = member.RentedMovies[choice - 1];
                        }
                    }
                }

                try
                {
                    Console.Clear();
                    Console.Write("Please wait...");
                    movieCollection.Tree.ReturnMovie(returnChoice);
                    member.RentedMovies.RemoveAt(choice - 1);
                }
                catch (Exception e)
                {
                    ErrorView.Error(e);
                }
            }
        }
Пример #5
0
        // MEMBER MENUS
        public void MemberMainMenu(Member member)
        {
            while (true)
            {
                Console.Clear();
                Console.Write("==========Member Menu==========\n" +
                              "Welcome, " + member.FirstName + ". Select from the options below.\n\n" +
                              " 1. Display all movies\n" +
                              " 2. Borrow a movie DVD\n" +
                              " 3. Return a movie DVD\n" +
                              " 4. List current borrowed movie DVDs\n" +
                              " 5. Display top 10 most popular movies\n" +
                              " 0. Return to main menu\n" +
                              "==============================\n\n" +
                              "Please make a selection (1-5, or 0 to return to main menu): ");
                string menuInput      = Console.ReadLine();
                bool   menuValidInput = int.TryParse(menuInput, out int menuChoice);

                if (menuValidInput)
                {
                    switch (menuChoice)
                    {
                    case 1:
                        MemberDisplayAllMovies();
                        break;

                    case 2:
                        MemberBorrowMovie(member);
                        break;

                    case 3:
                        MemberReturnMovie(member);
                        break;

                    case 4:
                        MemberListBorrowed(member);
                        break;

                    case 5:
                        MemberDisplayPopular();
                        break;

                    case 0:
                        MainMenu();
                        break;

                    default:
                        ErrorView.Error("Invalid selection. Please choose 1, 2, 3, 4, 5 or 0.");
                        break;
                    }
                }
            }
        }
Пример #6
0
        public void StaffRemoveMovie()
        {
            Console.Clear();
            Console.Write("==========Delete Movie==========\n" +
                          "Movie Name: ");
            string movieName = Console.ReadLine();

            try
            {
                Console.Clear();
                Console.Write("Please wait...");
                Movie result = movieCollection.Tree.Search(movieName);

                bool reviewValidInput = false;
                while (!reviewValidInput)
                {
                    Console.Clear();
                    Console.Write("==========Delete Movie==========\n" +
                                  "Please review the below information to ensure everything is correct.\n" +
                                  "\n Title: " + result.Title +
                                  "\n Starring: " + String.Join(",", result.Starring) +
                                  "\n Director: " + result.Director +
                                  "\n Duration: " + result.Duration + " mins" +
                                  "\n Genre: " + result.Genre.ToString() +
                                  "\n Classification: " + result.Classification.ToString() +
                                  "\n Release Date: " + result.ReleaseDate.ToString("dd/MM/yyyy") +
                                  "\n\nTo confirm deletion of this movie, press Y. To start again, press N.");
                    string reviewChoice = Console.ReadLine();

                    switch (reviewChoice.ToLower())
                    {
                    case "y":
                        Console.Clear();
                        Console.Write("Please wait...");
                        movieCollection.Tree.Remove(result);
                        return;

                    case "n":
                        return;
                    }

                    // no need for default as it will loop again if invalid response
                    Console.Beep();
                }
            }
            catch (Exception e)
            {
                ErrorView.Error(e);
            }
        }
Пример #7
0
        public void MemberLogin()
        {
            Console.Clear();
            Console.Write("==========Member Login==========\n" +
                          "Username: "******"Password: ");
            string password = Console.ReadLine();

            try
            {
                Member member = memberCollection.MemberLogin(userName, password);
                MemberMainMenu(member);
            }
            catch (Exception e)
            {
                ErrorView.Error(e);
            }
        }
Пример #8
0
        public void StaffLogin()
        {
            Console.Clear();
            Console.Write("==========Staff Login==========\n" +
                          "Username: "******"Password: "******"staff" && password == "today123")
            {
                this.StaffMainMenu();
            }
            else
            {
                ErrorView.Error("Invalid username and/or password. " +
                                "Please check your credentials and try again.");
            }
        }
Пример #9
0
        public void MainMenu()
        {
            while (true)
            {
                Console.Clear();
                Console.Write("Welcome to the Community Library\n" +
                              "============Main Menu===========\n" +
                              " 1. Staff Login\n" +
                              " 2. Member Login\n" +
                              " 0. Exit\n" +
                              "================================\n\n" +
                              "Please make a selection (1-2, or 0 to exit): ");
                string menuInput      = Console.ReadLine();
                bool   menuValidInput = int.TryParse(menuInput, out int menuChoice);

                if (menuValidInput)
                {
                    switch (menuChoice)
                    {
                    case 1:
                        this.StaffLogin();
                        break;

                    case 2:
                        this.MemberLogin();
                        break;

                    case 0:
                        Environment.Exit(0);
                        break;

                    default:
                        ErrorView.Error("Invalid selection. Please choose 1, 2 or 0.");
                        break;
                    }
                }
            }
        }
Пример #10
0
        public void MemberDisplayPopular()
        {
            List <Movie> movieList = movieCollection.Tree.Traverse();

            if (movieList.Count == 0)
            {
                ErrorView.Error("There are no movies yet.");
            }

            movieList = movieList.OrderByDescending(movie => movie.AmountBorrowed).Take(10).ToList();

            Console.Clear();
            Console.Write("==========Most Popular Movies==========\n" +
                          "Here are the top 10 most frequently borrowed movies.\n\n");

            for (int i = 0; i < movieList.Count; i++)
            {
                Console.WriteLine(i + 1 + ". " + movieList[i].Title + " - borrowed " + movieList[i].AmountBorrowed + " times.");
            }

            Console.Write("\nPress any key to return to the main menu.");
            Console.ReadKey();
        }
Пример #11
0
        public void StaffFindMember()
        {
            Console.Clear();
            Console.Write("==========Member Lookup==========\n" +
                          "First Name: ");
            string firstName = Console.ReadLine();

            Console.Write("Last Name: ");
            string lastName = Console.ReadLine();

            try
            {
                Member result = memberCollection.MemberSearch(firstName, lastName);
                Console.Write("==========Member Lookup==========\n" +
                              "Results: Phone number for " + firstName + " " + lastName + " is " + result.PhoneNumber +
                              "\nPress any key to return to the main menu.");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                ErrorView.Error(e);
            }
        }