Пример #1
0
        public static void ManagerPannel(Manager user)
        {
            while (true)
            {
                Console.WriteLine("Select: \n 1. Vehicle List \n 2. Store Managment \n  0. Exit");
                switch (Console.ReadLine())
                {
                case "1":
                    Console.WriteLine(ShopDB.ShowAllVehicles());
                    continue;

                case "2":
                    Console.WriteLine(ShopDB.ShowAllEmployees());
                    while (true)
                    {
                        Console.WriteLine("Pick an action");
                        Console.WriteLine("1. Fire an employee");
                        Console.WriteLine("2. Edit Salary");
                        switch (Console.ReadLine())
                        {
                        case "1":
                            while (true)
                            {
                                int id = 0;
                                Console.WriteLine("Who would you like fired?");
                                if (int.TryParse(Console.ReadLine(), out id))
                                {
                                    User selected = ShopDB.Users.FirstOrDefault(x => x.Id == id);
                                    if (selected == null)
                                    {
                                        Console.WriteLine("There are not employees with that ID");
                                        break;
                                    }
                                    else if (selected.Type == UserType.Manager)
                                    {
                                        Console.WriteLine("You cant fire Managers only the owner can edit them (in the code)");
                                        break;
                                    }
                                    ShopDB.Users.Remove(selected);
                                    break;
                                }
                                break;
                            }
                            continue;

                        case "2":
                            while (true)
                            {
                                int id = 0;
                                Console.WriteLine("Who would you like to edit?");
                                if (int.TryParse(Console.ReadLine(), out id))
                                {
                                    User selected = ShopDB.Users.FirstOrDefault(x => x.Id == id);
                                    if (selected == null)
                                    {
                                        Console.WriteLine("There are not employees with that ID");
                                        break;
                                    }
                                    else if (selected.Type == UserType.Manager)
                                    {
                                        Console.WriteLine("You cant edit Managers only the owner can edit them (in the code)");
                                        break;
                                    }
                                    UserUI.EditEmployeesSalary(user, (Supplyer)selected);
                                    break;
                                }
                                break;
                            }
                            continue;

                        case "0":
                            Helper.SlowPrint("Exiting menu");
                            break;

                        default:
                            Console.WriteLine("Invalid input");
                            continue;
                        }



                        break;
                    }
                    continue;

                case "0":
                    Helper.SlowPrint("Exiting");
                    break;

                default:
                    Console.WriteLine("Wrong Input");
                    continue;
                }
                break;
            }
        }
Пример #2
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;
            }
        }