Ejemplo n.º 1
0
        public static void CostumerPannel(Costumer user)
        {
            int selected = 0;

            while (true)
            {
                Console.WriteLine($"{user.GetInfo()}");
                Console.WriteLine("Select: \n 1. Buy \n 2. Browse \n 3. Add Funds \n 9. Change Password \n 0. Log Out");

                switch (Console.ReadLine())
                {
                case "1":
                    Console.Clear();
                    ShopDB.ShowCarsForBuyer();
                    Console.WriteLine("Select A car to Buy");

                    if (!int.TryParse(Console.ReadLine(), out selected) || selected > ShopDB.Vehicles.Count)
                    {
                        Console.WriteLine("Car does not exist");
                        continue;
                    }
                    if (selected == 0)
                    {
                        Console.WriteLine("Come Back again"); continue;
                    }
                    BuyCar(user, ShopDB.Vehicles[selected - 1]);

                    continue;

                case "2":
                    Console.WriteLine(ShopDB.ShowAllVehicles());
                    Console.ReadKey();
                    Console.Clear();
                    continue;

                case "3":
                    Helper.AddFunds(user);
                    continue;

                case "9":
                    Console.WriteLine("ChangePassword");
                    Console.WriteLine("Enter old password");
                    if (user.CheckPassword(Console.ReadLine()))
                    {
                        Console.WriteLine("Enter new password");
                        string password = Helper.PasswordValidation();
                        user.ChangePassword(password);
                        Console.WriteLine("Password Succesfully changed");
                    }
                    else
                    {
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Incorrect Password");
                        Console.ForegroundColor = ConsoleColor.White;
                    }

                    continue;

                case "0":
                    Helper.SlowPrint("Loging out...");
                    break;

                default:
                    Console.WriteLine("Wrong Input");
                    continue;
                }
                break;
            }
        }