Ejemplo n.º 1
0
        public static void addEmployeeCommand(Fabric fabric)
        {
            Console.Clear();
            Console.WriteLine("Add employee ===================================================================");

            Console.Write("Enter employee name: ");
            string name = Console.ReadLine();

            if (name.Equals(""))
            {
                Console.Clear();
                Console.WriteLine("Invalid name. Press any key to return to the main menu");
                Console.ReadKey();
                return;
            }

            Console.Write("Enter employee age: ");
            int age = int.Parse(Console.ReadLine());

            if (age < 18)
            {
                Console.Clear();
                Console.WriteLine("Invalid age. Press any key to return to the main menu");
                Console.ReadKey();
                return;
            }

            Employee employee = new Employee();

            employee.setInfo(name, age);

            Console.Write("Enter employee store: ");
            name = Console.ReadLine();

            if (name.Equals(""))
            {
                Console.Clear();
                Console.WriteLine("Invalid name. Press any key to return to the main menu");
                Console.ReadKey();
                return;
            }

            if (fabric.getStore(name) == null)
            {
                Console.Clear();
                Console.WriteLine("Store not found. Press any key to return to the main menu");
                Console.ReadKey();
                return;
            }

            fabric.getStore(name).addEmployee(employee);
            Console.WriteLine("Employee added. Press any key to return to the main menu");
        }