Ejemplo n.º 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;
            }
        }