private void AddAbsencePreferenceOnScheduler(Person pers)
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);
            List <AbsencePreference> scheduleAbsPreferencesSlotsWeek = bdModel.AbsencePreferences.Where(ws => ws.idPerson == pers.idPerson).ToList();

            //Get all the current week's scheduleSlots

            scheduleAbsPreferencesSlotsWeek = PlanningGeneratorTools.GetAbsPreferenceSlots(slotGenerationScheduler.SelectedDate, bdModel);
            scheduleAbsPreferencesSlotsWeek = scheduleAbsPreferencesSlotsWeek.Where(a => a.idPerson == pers.idPerson).ToList();

            //Add the week's slot in the scheduler
            foreach (AbsencePreference ss in scheduleAbsPreferencesSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = ss.idPerson.ToString() + " " + ss.Person.firstName + " " + ss.Person.name + Environment.NewLine + Environment.NewLine +
                              "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDate.ToString("MM/dd/yyyy"),
                    Start     = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End       = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek = ss.dayOfWeek,
                    Color     = new SolidColorBrush(Colors.Aqua),
                    FirstDay  = ss.firstDay,
                    LastDay   = ss.lastDate,
                    IdShift   = ss.idTimeSlot
                });
            }
        }
        public void LoadScheduleSlotFromDatabase()
        {
            //Clear events in the current scheduler
            PlanningGeneratorTools.ClearWorkingShiftScheduler(slotGenerationScheduler);

            DateTime d = slotGenerationScheduler.SelectedDate;
            //DateTime lastSunday = PlanningGeneratorTools.GetMondayBefore(d).AddDays(-1);
            DateTime lastSunday;

            //d is sunday ?
            if (d.DayOfWeek == DayOfWeek.Sunday)
            {
                lastSunday = d.AddDays(-7);
            }
            else
            {
                lastSunday = PlanningGeneratorTools.GetSundayAfter(d).AddDays(-7);
            }

            List <AbsencePreference> scheduleAbsPreferencesSlotsWeek;

            //Get all the current week's scheduleSlots
            scheduleAbsPreferencesSlotsWeek = PlanningGeneratorTools.GetAbsPreferenceSlots(d, bdModel);

            //Add the week's slot in the scheduler
            foreach (AbsencePreference ss in scheduleAbsPreferencesSlotsWeek)
            {
                slotGenerationScheduler.AddEvent(new Event()
                {
                    Subject = ss.idPerson.ToString() + " " + ss.Person.firstName + " " + ss.Person.name + Environment.NewLine + Environment.NewLine +
                              "Date départ : " + ss.firstDay.ToString("MM/dd/yyyy") + Environment.NewLine + Environment.NewLine +
                              "Date de fin : " + ss.lastDate.ToString("MM/dd/yyyy"),
                    Start     = lastSunday.AddDays(ss.dayOfWeek).Add(ss.startHour),
                    End       = lastSunday.AddDays(ss.dayOfWeek).Add(ss.endHour),
                    DayOfWeek = ss.dayOfWeek,
                    Color     = new SolidColorBrush(Colors.Aqua),
                    FirstDay  = ss.firstDay,
                    LastDay   = ss.lastDate,
                    IdShift   = ss.idTimeSlot,
                });
            }
            cbxPeople.SelectedIndex = -1;
            btnSlotScheduleGeneration.Visibility = Visibility.Hidden;
        }