Beispiel #1
0
        /// <summary>
        /// Adds worker to the organization workers' list.
        /// Worker must have valid dept ID.
        /// Number of workers of the specified department is increased by 1
        /// </summary>
        /// <param name="worker">worker</param>
        /// <returns>
        ///  0 if worker was added successfully
        /// -1 if worker with same ID already exists
        /// -2 if director is already exists
        /// </returns>
        public int AddWorker(IWorker worker)
        {
            // Check if a being added worker does not have same ID as someone else
            if (Workers.Find(w => w.ID == worker.ID) != null)
            {
                return(-1);
            }

            var d = Department(worker.DeptID);

            Workers.Add(worker as Worker);
            d.NumberOfEmployees++;
            UpdateSalaries(d as BaseDepartment);
            return(0);
        }
        /// <summary>
        /// Finds director (president,head) of department
        /// </summary>
        /// <param name="d">Department</param>
        /// <returns>
        /// Worker of the Director class or
        /// null if a director of deptID department is not found
        /// </returns>
        public IWorker Director(IDepartmentDTO d)
        {
            Director dir = Workers.Find(w => w.DeptID == d.DeptID && w is Director) as Director;

            return(dir);
        }