Beispiel #1
0
        public void AssignEmployeeToShift(int employeeID, DateTime day, int shiftNumber)
        {
            int      primaryShiftNumber = shiftNumber;
            Employee employee           = fullListemployees.Find(x => x.WorkrID == employeeID);

            if (shiftNumber == 4)
            {
                Shift secondaryShift = FindShift(day, 2);
                secondaryShift.AssignEmployee(employee);
                primaryShiftNumber = 1;
                if (!stageforChanges.Exists(i => i.ShiftID == secondaryShift.ShiftID))
                {
                    stageforChanges.Add(secondaryShift);
                }
            }
            if (shiftNumber == 5)
            {
                Shift secondaryShift = FindShift(day, 3);
                secondaryShift.AssignEmployee(employee);
                primaryShiftNumber = 2;
                if (!stageforChanges.Exists(i => i.ShiftID == secondaryShift.ShiftID))
                {
                    stageforChanges.Add(secondaryShift);
                }
            }
            if (shiftNumber == 6)
            {
                Shift secondaryShift = FindShift(day, 2);
                secondaryShift.AssignEmployee(employee);
                Shift tretiaryShift = FindShift(day, 3);
                tretiaryShift.AssignEmployee(employee);
                primaryShiftNumber = 1;
                if (!stageforChanges.Exists(i => i.ShiftID == secondaryShift.ShiftID))
                {
                    stageforChanges.Add(secondaryShift);
                }
                if (!stageforChanges.Exists(i => i.ShiftID == tretiaryShift.ShiftID))
                {
                    stageforChanges.Add(tretiaryShift);
                }
            }
            Shift shift = FindShift(day, primaryShiftNumber);

            shift.AssignEmployee(employee);

            if (!stageforChanges.Exists(i => i.ShiftID == shift.ShiftID))
            {
                stageforChanges.Add(shift);
            }
        }