Example #1
0
        public void Work()
        {
            Console.WriteLine("Enter FirstName");
            var firstName = Console.ReadLine();

            var position = GetSelectedPosition();

            if (position == Position.Worker)
            {
                Worker currentEmployee = Workers.FirstOrDefault(e => e.Name == firstName);

                currentEmployee.Work(currentEmployee.Task);
            }

            if (position == Position.Taskmaster)
            {
                Taskmaster currentTaskmaster = Taskmasters.FirstOrDefault(e => e.Name == firstName);

                Taskmaster.Work(currentTaskmaster.Task);
            }

            if (position == Position.Manager)
            {
                Manager currentManager = Managers.FirstOrDefault(e => e.Name == firstName);

                Manager.Work(currentManager.Task);
            }
        }
Example #2
0
 public void CheckWorkersTask()
 {
     Console.Clear();
     if (Workers.Count == 0)
     {
         Console.WriteLine("There are no tasks at the moment");
     }
     else
     {
         Taskmaster.CheckWorker(Workers);
     }
 }
Example #3
0
        public void RemoveEmployee()
        {
            var position = GetSelectedPosition();

            Console.WriteLine("Enter FirstName to delete");
            var firstName = Console.ReadLine();

            if (position == Position.Worker)
            {
                Worker currentWorker = Workers.FirstOrDefault(e => e.Name == firstName);

                if (currentWorker != null)
                {
                    Workers.Remove(currentWorker);
                }
            }

            if (position == Position.Taskmaster)
            {
                Taskmaster currentTaskmaster = Taskmasters.FirstOrDefault(e => e.Name == firstName);

                if (currentTaskmaster != null)
                {
                    Taskmasters.Remove(currentTaskmaster);
                }
            }

            if (position == Position.Manager)
            {
                Manager currentManager = Managers.FirstOrDefault(e => e.Name == firstName);

                if (currentManager != null)
                {
                    Managers.Remove(currentManager);
                }
            }
        }
Example #4
0
        public void CreateEmployee()
        {
            Console.Clear();
            Console.WriteLine("Enter Name");
            var firstName = Console.ReadLine();

            Console.WriteLine("Enter LastName");
            var lastName = Console.ReadLine();

            Console.WriteLine("Enter Middle");
            var middle = Console.ReadLine();

            Console.WriteLine("Enter experience");
            double experience = 0;

            try
            {
                experience = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception)
            {
                Console.WriteLine("Wrong experience");
            }

            Console.WriteLine("Enter Task");
            var task = Console.ReadLine();


            var position = GetSelectedPosition();

            if (position == Position.Worker)
            {
                Worker worker = new Worker(firstName, lastName, middle, experience, Position.Worker, task);

                if (ContainEmployee(worker.Name, worker.Position))
                {
                    Console.WriteLine("This employee exist. Try again");
                    CreateEmployee();
                }
                Workers.Add(worker);
            }

            if (position == Position.Taskmaster)
            {
                var taskmaster = new Taskmaster(firstName, lastName, middle, experience, Position.Worker, task);

                if (ContainEmployee(taskmaster.Name, taskmaster.Position))
                {
                    Console.WriteLine("This employee exist. Try again");
                    CreateEmployee();
                }

                Taskmasters.Add(taskmaster);
            }

            if (position == Position.Manager)
            {
                var manager = new Manager(firstName, lastName, middle, experience, Position.Worker, task);

                if (ContainEmployee(manager.Name, manager.Position))
                {
                    Console.WriteLine("This employee exist. Try again");
                    CreateEmployee();
                }

                Managers.Add(manager);
            }
        }