コード例 #1
0
        private void UpdateRental()
        {
            _rentalManager.GetList(_rentalManager.GetAll().Data);

            bool flag2  = true;
            int  choice = 0;

            while (flag2)
            {
                Console.WriteLine("Please select the ID of your rental transaction record: ");
                choice = Convert.ToInt32(Console.ReadLine());
                var list = _rentalManager.GetAll().Data;
                if (!list.Any(x => x.ID == choice))
                {
                    Console.WriteLine(Messages.NotExist + "rental transaction");
                }
                else
                {
                    flag2 = false;
                }
            }
            var    rent     = _rentalManager.FindByID(choice).Data;
            bool   flag3    = true;
            string email    = " ";
            var    customer = new User();

            while (flag3)
            {
                Console.WriteLine("Please enter your registered email address: ");
                email    = Console.ReadLine();
                customer = _userManager.FindByID(rent.CustomerID).Data;
                if (customer.Email != email)
                {
                    Console.WriteLine(Messages.NotExist + "email address.");
                }
                else
                {
                    flag3 = false;
                }
            }
            bool flag4 = true;
            //string password = "******";
            //while (flag4)
            //{
            //    Console.WriteLine("Please enter your password: "******"user.");
            //    }
            //    else flag4 = false;
            //}
            var car = _carManager.FindByID(rent.CarID).Data;

            car.IsRented = false;
            _carManager.Update(car);
            Console.WriteLine("Please enter the rent date: ");
            rent.ReturnDate = DateTime.Parse(Console.ReadLine());
            _rentalManager.Update(rent);
            Console.WriteLine(Messages.ReturnSuccess);
        }