Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var workers = DB.Employees.Where(m => m.Grade = EmployeeGrade.Worker).ToList();

            Console.WriteLine("Anzahl Mitarbeiter: {0}" + workers.Count);

            for (var i = 1; i <= workers.Count; i++)
                Console.WriteLine("Mitarbeiter {0}: {1}", i, workers[i].Name);

            var youngest = FindRecentYoungestAsync(workers).Result;

            Console.WriteLine("Jüngster Mitarbeiter (seit diesem Jahr): {0} ({1} Jahre)", youngest.Name, youngest.Age);

            var maxWorker = new Employee();
            int most = int.MaxValue;

            foreach (var employee in DB.Employees)
            {
                var sum = 0;

                foreach (var project in DB.Projects)
                {
                    if (project.Responsible == employee)
                        sum++;
                    else
                    {
                        foreach (var worker in project.Workers)
                            if (worker == employee)
                                sum++;
                    }
                }

                if (sum < most)
                {
                    most = sum;
                    maxWorker = employee;
                }

                Console.WriteLine("{1} arbeitet an {2} Projekten mit.", employee.Name, sum);
            }

            Console.WriteLine("{0} ist an {1} Projekten beteiligt ...", maxWorker.Name, most);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes an employee. Does not remove his / her location.
 /// </summary>
 /// <param name="employee">The employee to remove.</param>
 public static void RemoveEmployee(Employee employee)
 {
     employees.Remove(employee);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds another employee and (if not already done) his / her location.
        /// </summary>
        /// <param name="employee">The employee to add.</param>
        public static void AddEmployee(Employee employee)
        {
            employees.Add(employee);

            if(!locations.Contains(employee.Home))
                AddLocation(employee.Home);
        }