public static AppointmentEntity TrainingFrenchLesson()
        {
            DateTime start    = Start.AddDays(-7).AddHours(11).AddMinutes(10);
            DateTime newStart = start;
            DateTime newEnd   = newStart.AddHours(1.5);
            var      appt     = new AppointmentEntity()
            {
                AppointmentType = (int)AppointmentType.Pattern,
                Start           = newStart,
                End             = newEnd,
                ResourceId      = 2,
                Subject         = "French lesson",
                Label           = 3,
                Description     =
                    "Another french lesson.Once again, without mastering French, our success on the Continent will be less likely.Everyone needs to learn French.",
            };

            appt.RecurrenceInfo = RecurrenceBuilder.Weekly(newStart, 10)
                                  .ByDay(WeekDays.Monday | WeekDays.Wednesday)
                                  .Build()
                                  .ToXml();
            return(appt);
        }
        public static AppointmentEntity TrainingGermanLesson()
        {
            DateTime start    = Start.AddHours(15).AddMinutes(40);
            DateTime newStart = start;
            DateTime newEnd   = newStart.AddHours(1.5);
            var      appt     = new AppointmentEntity()
            {
                AppointmentType = (int)AppointmentType.Pattern,
                Start           = newStart,
                End             = newEnd,
                ResourceId      = 2,
                Subject         = "German lesson",
                Label           = 3,
                Description     =
                    "We're learning French but we also need to become fluent in German. The German market for A/V products is huge. We need to be able to communicate in German if we are to have any luck in Germany."
            };

            appt.RecurrenceInfo = RecurrenceBuilder.Weekly(newStart, 10)
                                  .ByDay(WeekDays.Tuesday | WeekDays.Friday)
                                  .Build()
                                  .ToXml();
            return(appt);
        }
        public static IEnumerable <AppointmentEntity> Gym()
        {
            DateTime start = Start.AddMonths(-1).AddHours(18);

            TimeSpan patternTimeOfDay = start.TimeOfDay;
            DateTime patternStartDate = DateTimeHelper.GetStartOfWeekUI(start.Date, DayOfWeek.Monday).Date;
            DateTime patternStart     = patternStartDate + patternTimeOfDay;

            TimeSpan          patternDuration = TimeSpan.FromHours(1.5);
            AppointmentEntity pattern         = new AppointmentEntity()
            {
                AppointmentType = (int)AppointmentType.Pattern,
                Start           = patternStart,
                End             = patternStart + patternDuration,
                Subject         = "Gym",
                Label           = 3,
                ResourceId      = 1
            };

            RecurrenceInfo info = (RecurrenceInfo)RecurrenceBuilder.Weekly(patternStart)
                                  .ByDay(WeekDays.Monday | WeekDays.Wednesday | WeekDays.Friday)
                                  .Build();

            pattern.RecurrenceInfo = info.ToXml();
            DateTime weekStartDate          = DateTimeHelper.GetStartOfWeekUI(Start.Date, DayOfWeek.Monday).Date;
            DateTime changedStart           = weekStartDate + patternTimeOfDay + TimeSpan.FromHours(-1);
            int      changedOccurrenceIndex = (weekStartDate - patternStartDate).Days / 7 * 3;

            if (changedOccurrenceIndex < 0)
            {
                return new List <AppointmentEntity>(1)
                       {
                           pattern
                       }
            }
            ;

            AppointmentEntity changedOccurrence = new AppointmentEntity()
            {
                AppointmentType = (int)AppointmentType.ChangedOccurrence,
                Start           = changedStart,
                End             = changedStart + patternDuration,
                Subject         = "Gym",
                Label           = 3,
                ResourceId      = 1
            };

            changedOccurrence.RecurrenceInfo = new PatternReferenceXmlPersistenceHelper(new PatternReference(info.Id,
                                                                                                             changedOccurrenceIndex)).ToXml();
            int      deletedOccurrenceIndex = changedOccurrenceIndex + 1;
            DateTime deletedStart           = weekStartDate + patternTimeOfDay + TimeSpan.FromDays(2);

            AppointmentEntity deletedOccurrence = new AppointmentEntity()
            {
                AppointmentType = (int)AppointmentType.DeletedOccurrence,
                Start           = deletedStart,
                End             = deletedStart + patternDuration,
                Subject         = "Gym",
                Label           = 3,
                ResourceId      = 1
            };

            deletedOccurrence.RecurrenceInfo = new PatternReferenceXmlPersistenceHelper(new PatternReference(info.Id,
                                                                                                             deletedOccurrenceIndex)).ToXml();
            return(new List <AppointmentEntity>(3)
            {
                pattern, changedOccurrence, deletedOccurrence
            });
        }