Beispiel #1
0
        public int AddCalendarEvent(EventViewModel calendarEvent, bool isUpdated = false)
        {
            int id     = _evRepository.AddCalendarEvent(_mapper.Map <EventViewModel, Event>(calendarEvent)).Id;
            var @event = _evRepository.GetEvent(id);

            if (isUpdated)
            {
                _notificationSender.ScheduleEventEditedNotification(@event.Id);
            }
            else
            {
                _notificationSender.ScheduleEventCreatedNotification(@event.Id);
            }

            var seriesId = @event.SeriesId.GetValueOrDefault();

            if (@event.Reiteration != null)
            {
                GenerateEventsOfSeries(calendarEvent, seriesId);

                if (@event.NotificationTime != null)
                {
                    _notificationSender.ScheduleEventSeriesStartedNotification(seriesId);
                }
            }
            else if (@event.NotificationTime != null && @event.NotificationScheduleJobId == null)
            {
                _notificationSender.ScheduleEventStartedNotification(@event.Id);
            }

            return(@event.Id);
        }