Пример #1
0
        public static void ChooseEmployeeAction()
        {
            Console.Clear();

            while (true)
            {
                Console.WriteLine("Manage your employees");
                Console.WriteLine("1. View all employees");
                Console.WriteLine("2. View all employees by department");
                Console.WriteLine("3. Get employee by Id");
                Console.WriteLine("4. Add employee");
                Console.WriteLine("5. Update employee");
                Console.WriteLine("6. Delete employee");
                Console.WriteLine("7. Main menu");
                Console.WriteLine();

                Console.WriteLine("Choose a menu option");
                Console.Write("> ");

                string option = Console.ReadLine();

                if (option == "1")
                {
                    EmployeeList.ListEmployees();
                }
                if (option == "2")
                {
                    EmployeeListByDepartment.ListEmployeesWithDepartment();
                }
                if (option == "3")
                {
                    FindEmployee.CollectId();
                }
                if (option == "4")
                {
                    AddEmployee.CollectInput();
                }
                if (option == "5")
                {
                    UpdateEmployee.CollectInput();
                }
                if (option == "6")
                {
                    DeleteEmployee.CollectInput();
                }
                if (option == "7")
                {
                    Console.Clear();
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Clear();
                Console.WriteLine("YYYYYYYYYOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\n");

                Console.WriteLine("1. Get all departments");

                Console.WriteLine("2. Get department by ID");

                Console.WriteLine("3. Add a department");

                Console.WriteLine("4. Update a department");

                Console.WriteLine("5. Delete a department");

                Console.WriteLine("6. Get all employees");

                Console.WriteLine("7. Get employee by ID");

                Console.WriteLine("8. Get employees with their department");

                Console.WriteLine("9. Add a employee");

                Console.WriteLine("10. Update a employee");

                Console.WriteLine("11. Delete a employee");

                Console.WriteLine("12. Exit");

                Console.WriteLine("YYYYYYYYYOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\n");


                Console.WriteLine("Please Select an Action?");
                Console.Write("> ");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    GetAllDepartments.CollectInput();
                }

                else if (option == "2")
                {
                    DepartmentById.CollectInput();
                }

                else if (option == "3")
                {
                    AddDepartment.CollectInput();
                }

                else if (option == "4")
                {
                    UpdateDepartment.CollectInput();
                }

                else if (option == "5")
                {
                    DeleteDepartment.CollectInput();
                }

                else if (option == "6")
                {
                    GetAllEmployees.CollectInput();
                }

                else if (option == "7")
                {
                    EmployeeById.CollectInput();
                }

                else if (option == "8")
                {
                    EmployeesWithDepartment.CollectInput();
                }

                else if (option == "9")
                {
                    AddEmployee.CollectInput();
                }

                else if (option == "10")
                {
                    UpdateEmployee.CollectInput();
                }

                else if (option == "11")
                {
                    DeleteEmployee.CollectInput();
                }

                else if (option == "12")
                {
                    Console.WriteLine("Exit");
                    Console.ReadLine();
                    break;
                }

                else
                {
                    Console.WriteLine($"Invalid : {option}");
                    Console.WriteLine($"");
                    Console.ReadLine();
                }
            }
        }