Exemple #1
0
 private void OnVacationDatesEdit(VacationDatesAreEdited message)
 {
     if (this.EventsById.TryGetValue(message.EventId, out var calendarEvent))
     {
         var newDates = new DatesPeriod(message.StartDate, message.EndDate);
         this.EventsById[message.EventId] = new CalendarEvent(message.EventId, calendarEvent.Type, newDates, calendarEvent.Status, this.EmployeeId);
     }
 }
Exemple #2
0
        protected override void UpdateCalendarEvent(CalendarEvent oldEvent, CalendarEvent newEvent, OnSuccessfulUpsertCallback onUpsert)
        {
            if (oldEvent.Dates != newEvent.Dates)
            {
                var eventToPersist = new VacationDatesAreEdited()
                {
                    EventId   = newEvent.EventId,
                    StartDate = newEvent.Dates.StartDate,
                    EndDate   = newEvent.Dates.EndDate,
                    TimeStamp = DateTimeOffset.Now
                };
                this.Persist(eventToPersist, this.OnVacationDatesEdit);
            }

            if (oldEvent.Status != newEvent.Status)
            {
                switch (newEvent.Status)
                {
                case VacationStatuses.Approved:
                    this.Persist(new VacationIsApproved()
                    {
                        EventId   = newEvent.EventId,
                        TimeStamp = DateTimeOffset.Now
                    }, this.OnVacationApproved);
                    break;

                case VacationStatuses.Cancelled:
                    this.Persist(new VacationIsCancelled()
                    {
                        EventId   = newEvent.EventId,
                        TimeStamp = DateTimeOffset.Now
                    }, this.OnVacationCancel);
                    break;

                case VacationStatuses.Rejected:
                    this.Persist(new VacationIsRejected()
                    {
                        EventId   = newEvent.EventId,
                        TimeStamp = DateTimeOffset.Now,
                    }, this.OnVacationRejected);
                    break;
                }
            }

            onUpsert(newEvent);
        }