public CalendarEntryParticipantUninvited(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId, Participant participant)
        {
            this.TenantId = tenantId;
            this.CalendarId = calendarId;
            this.CalendarEntryId = calendarEntryId;
            this.Participant = participant;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public CalendarEntryRelocated(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId, string location)
        {
            this.TenantId = tenantId;
            this.CalendarId = calendarId;
            this.CalendarEntryId = calendarEntryId;
            this.Location = location;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public CalendarEntryDescriptionChanged(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId, string description)
        {
            this.TenantId = tenantId;
            this.CalendarId = calendarId;
            this.CalendarEntryId = calendarEntryId;
            this.Description = description;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public CalendarEntryRescheduled(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId,
            DateRange timeSpan, Repetition repetition, Alarm alarm)
        {
            this.TenantId = tenantId;
            this.CalendarId = calendarId;
            this.CalendarEntryId = calendarEntryId;
            this.TimeSpan = timeSpan;
            this.Repetition = repetition;
            this.Alarm = alarm;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public CalendarEntryScheduled(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId,
            string description, string location, Owner owner, DateRange timeSpan, Repetition repetition, Alarm alarm,
            IEnumerable<Participant> invitees)
        {
            this.TenantId = tenantId;
            this.CalendarId = calendarId;
            this.CalendarEntryId = calendarEntryId;
            this.Description = description;
            this.Location = location;
            this.Owner = owner;
            this.TimeSpan = timeSpan;
            this.Repetition = repetition;
            this.Alarm = alarm;
            this.Invitees = invitees;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public CalendarEntry(TenantId tenantId, CalendarId calendarId, CalendarEntryId calendarEntryId,
            string description, string location, Owner owner, DateRange timeSpan, Repetition repetition, 
            Alarm alarm, IEnumerable<Participant> invitees = null)
        {
            AssertionConcern.NotNull(tenantId, "The tenant must be provided.");
            AssertionConcern.NotNull(calendarId, "The calendar id must be provided.");
            AssertionConcern.NotNull(calendarEntryId, "The calendar entry id must be provided.");
            AssertionConcern.NotEmpty(description, "The description must be provided.");
            AssertionConcern.NotEmpty(location, "The location must be provided.");
            AssertionConcern.NotNull(owner, "The owner must be provided.");
            AssertionConcern.NotNull(timeSpan, "The time span must be provided.");
            AssertionConcern.NotNull(repetition, "The repetition must be provided.");
            AssertionConcern.NotNull(alarm, "The alarm must be provided.");

            if(repetition.Repeats==RepeatType.DoesNotRepeat) {
                repetition = Repetition.DoesNotRepeat(timeSpan.Ends);
            }

            AssertTimeSpans(repetition, timeSpan);

            this.Apply(new CalendarEntryScheduled(tenantId, calendarId, calendarEntryId, description, location, owner,
                timeSpan, repetition, alarm, invitees));
        }
 private void When(CalendarEntryScheduled e)
 {
     this._tenantId = e.TenantId;
     this._calendarId = e.CalendarId;
     this._calendarEntryId = e.CalendarEntryId;
     this._description = e.Description;
     this._location = e.Location;
     this._owner = e.Owner;
     this._timeSpan = e.TimeSpan;
     this._repetition = e.Repetition;
     this._alarm = e.Alarm;
     this._invitees = new HashSet<Participant>(e.Invitees ?? Enumerable.Empty<Participant>());
 }