Beispiel #1
0
        private void ReturnMovie()
        {
            var flag       = true;
            var lateReturn = false;
            var title      = "";
            var ssn        = "";

            while (flag)
            {
                var menuString = $@"
RETURN MOVIE.   Enter EXIT to Abort.

Movie title:
";
                Console.WriteLine(menuString);
                if (Abort(title = Console.ReadLine()))
                {
                    Console.Clear(); return;
                }
                Console.WriteLine("Customer SocialSecurityNumber: ");
                if (Abort(ssn = Console.ReadLine()))
                {
                    Console.Clear(); return;
                }
                try
                {
                    _videoStore.ReturnMovie(title, ssn);
                    flag = false;
                }
                catch (InvalidSocialSecurityNumberExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (CustomerDontExistsExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (MovieDontExistsExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (LateRentalExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                    lateReturn = true;
                    flag       = false;
                }
            }
            Console.Clear();
            if (lateReturn)
            {
                ConsoleWrite.Error("Late Return!");
            }

            ConsoleWrite.Success("Return Succeded! Movie: " + title + ". Customer: " + ssn);
        }
Beispiel #2
0
        private void RegisterCustomer()
        {
            var flag = true;
            var name = "";
            var ssn  = "";

            while (flag)
            {
                var menuString1 = $@"


EnterName:
";
                ConsoleWrite.Heading("REGISTER NEW CUSTOMER.   Enter EXIT to Abort.");
                Console.WriteLine(menuString1);
                name = Console.ReadLine();
                if (Abort(name))
                {
                    return;
                }
                Console.WriteLine("Enter SocialSecurityNumber: (YYY-MM-DD)");
                ssn = Console.ReadLine();
                if (Abort(ssn))
                {
                    return;
                }
                try
                {
                    _videoStore.RegisterCustomer(ssn, name);
                    flag = false;
                }
                catch (InvalidSocialSecurityNumberExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (NameNullOrEmptyExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (CustomerExistsExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
            }
            Console.Clear();
            ConsoleWrite.Success("Registration Succeded! Name: " + name + ". SocialSecurityNumber: " + ssn);
        }
Beispiel #3
0
        private void GetCustomer()
        {
            ConsoleWrite.Heading("GET CUSTOMER.  enter Exit to abort." + Environment.NewLine);
            Console.WriteLine("Enter SocialSecurityNumber:");
            var           ssn      = "";
            List <Rental> rentals  = new List <Rental>();
            Customer      customer = new Customer();

            if (Abort(ssn = Console.ReadLine()))
            {
                Console.Clear(); return;
            }
            try
            {
                rentals = _rentals.GetRentalsFor(ssn);
            }
            catch (Exception ex)
            {
                Console.Clear();
                ConsoleWrite.Error(ex.Message.ToString());
            }
            try
            {
                customer = (_videoStore.GetCustomers()).FirstOrDefault(x => x.SSN == ssn);
            }
            catch (Exception ex)
            {
                Console.Clear();
                ConsoleWrite.Error(ex.Message.ToString());
            }

            Console.WriteLine("*  Name: " + customer.Name + " - SocialSecurityNumber: " + customer.SSN);
            Console.WriteLine("Rentals:");
            if (rentals.Count == 0)
            {
                Console.WriteLine("No rentals");
            }
            else
            {
                foreach (var rent in rentals)
                {
                    Console.WriteLine("Title: " + rent._movieTitle + "Shud be returned before: " + rent._dueDate);
                    if (rent.IsLate())
                    {
                        ConsoleWrite.Error("MOVIE IS LATE!");
                    }
                }
            }
        }
Beispiel #4
0
        private void AddMovie()
        {
            var flag  = true;
            var title = "";

            while (flag)
            {
                var menuString = $@"
ADD NEW MOVIE.   Enter EXIT to Abort.

Movie title:
";
                Console.WriteLine(menuString);
                if (Abort(title = Console.ReadLine()))
                {
                    Console.Clear(); return;
                }

                try
                {
                    _videoStore.AddMovie(new Movie(title, MovieGenre.Action));
                    flag = false;
                }
                catch (MovieTitelsIsNullOrEmptyExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
                catch (MovieTitleOverloadExeption ex)
                {
                    Console.Clear();
                    ConsoleWrite.Error(ex.Message.ToString());
                }
            }
            Console.Clear();


            ConsoleWrite.Success("Add Movie Succeded: " + title + " Genre: " + "");
        }
Beispiel #5
0
 internal static void ErrorInput()
 {
     ConsoleWrite.Error("ERROR. wrong input.");
 }