コード例 #1
0
        public void DeleteFollowingInspections()
        {
            //Alle nachfolgenden Termine finden
            Approval_Inspection[] followingInspections;
            if (m_SelectedInspection.DueDate.IsAllDay)
            {
                followingInspections = m_AllInspections.Where(flr => flr.DueDate.Begin.Date >= m_SelectedInspection.DueDate.Begin.Date)
                                       .ToArray();
            }
            else
            {
                followingInspections = m_AllInspections.Where(flr => flr.DueDate.Begin >= m_SelectedInspection.DueDate.Begin)
                                       .ToArray();
            }

            //Serie ggf. löschen
            if (!m_AllInspections.Except(followingInspections)
                .Any())
            {
                m_Repository.DeleteObject(m_Model);
            }
            else
            {
                //Ende der alten Serie anpassen
                if (EndsWithDate)
                {
                    m_Model.RepeatUntilDate = m_SelectedInspection.DueDate.Begin;
                }
                else
                {
                    m_Model.NumberOfRecurrences = m_Model.NumberOfRecurrences - followingInspections.Count();
                }
            }

            //Alle folgenden Termine löschen
            foreach (var followingReading in followingInspections)
            {
                DeleteReadingFromRepository(followingReading);
            }
            m_Repository.Save();
            TryClose();
        }