private void ValidatePopupReminderSettings(Event entity, bool isNew)
        {
            IList <EventPopupReminderSetting> popupReminderSettings = entity.PopupReminderSettings;

            if (popupReminderSettings == null)
            {
                throw new NullPopupReminderSettingsException();
            }
            if (popupReminderSettings.Count != 1)
            {
                throw new InvalidPopupReminderSettingsCountException(popupReminderSettings.Count);
            }
            EventPopupReminderSetting eventPopupReminderSetting = popupReminderSettings[0];

            if (eventPopupReminderSetting == null)
            {
                throw new NullPopupReminderSettingsException();
            }
            if (isNew)
            {
                if (!string.IsNullOrEmpty(eventPopupReminderSetting.Id))
                {
                    throw new InvalidNewReminderSettingIdException();
                }
            }
            else if (eventPopupReminderSetting.Id != EventPopupReminderSettingsRules.GetDefaultPopupReminderSettingId(entity))
            {
                throw new InvalidReminderSettingIdException();
            }
        }
示例#2
0
 internal static void MergeMasterAndInstanceProperties(this Event occurrence, Event master, bool isNew, Func <Event, Event, PropertyDefinition, bool> shouldCopyProperty)
 {
     if (shouldCopyProperty(master, occurrence, master.Schema.AttachmentsProperty))
     {
         occurrence.Attachments = master.Attachments;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.AttendeesProperty))
     {
         occurrence.Attendees = master.Attendees;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.BodyProperty))
     {
         occurrence.Body = master.Body;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.CalendarProperty))
     {
         occurrence.Calendar = master.Calendar;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.CategoriesProperty))
     {
         occurrence.Categories = master.Categories;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.HasAttachmentsProperty))
     {
         occurrence.HasAttachments = master.HasAttachments;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.IntendedEndTimeZoneIdProperty))
     {
         occurrence.IntendedEndTimeZoneId = master.IntendedEndTimeZoneId;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.IntendedStartTimeZoneIdProperty))
     {
         occurrence.IntendedStartTimeZoneId = master.IntendedStartTimeZoneId;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.ImportanceProperty))
     {
         occurrence.Importance = master.Importance;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.LocationProperty))
     {
         occurrence.Location = master.Location;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.PreviewProperty))
     {
         occurrence.Preview = master.Preview;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.ResponseRequestedProperty))
     {
         occurrence.ResponseRequested = master.ResponseRequested;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.SensitivityProperty))
     {
         occurrence.Sensitivity = master.Sensitivity;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.SeriesIdProperty))
     {
         occurrence.SeriesId = master.SeriesId;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.ShowAsProperty))
     {
         occurrence.ShowAs = master.ShowAs;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.SubjectProperty))
     {
         occurrence.Subject = master.Subject;
     }
     if (isNew)
     {
         occurrence.ClientId = master.ClientId;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.InternalIsReceived))
     {
         ((IEventInternal)occurrence).IsReceived = ((IEventInternal)master).IsReceived;
     }
     if (shouldCopyProperty(master, occurrence, master.Schema.PopupReminderSettingsProperty) && master.PopupReminderSettings != null && master.PopupReminderSettings.Count == 1 && master.PopupReminderSettings[0] != null)
     {
         EventPopupReminderSetting eventPopupReminderSetting = master.PopupReminderSettings[0];
         occurrence.PopupReminderSettings = new List <EventPopupReminderSetting>
         {
             new EventPopupReminderSetting
             {
                 Id            = (isNew ? null : EventPopupReminderSettingsRules.GetDefaultPopupReminderSettingId(occurrence)),
                 IsReminderSet = eventPopupReminderSetting.IsReminderSet,
                 ReminderMinutesBeforeStart = eventPopupReminderSetting.ReminderMinutesBeforeStart
             }
         };
     }
 }