Пример #1
0
        public async Task <ScheduledPresentation> SaveScheduledPresentationAsync(ScheduledPresentation scheduledPresentation)
        {
            // Validate the fields
            if (scheduledPresentation == null)
            {
                throw new ArgumentNullException(nameof(scheduledPresentation), "The scheduled presentation can not be null");
            }

            if (scheduledPresentation.Presentation == null)
            {
                throw new ArgumentNullException(nameof(scheduledPresentation.Presentation), "The presentation can not be null");
            }

            // Rules validation
            if (scheduledPresentation.StartTime > scheduledPresentation.EndTime)
            {
                throw new ArgumentOutOfRangeException(nameof(scheduledPresentation.StartTime),
                                                      scheduledPresentation.StartTime,
                                                      "The start time of the presentation can not be greater then the end time");
            }

            var savedScheduledPresentation = await _presentationRepository.SaveScheduledPresentationAsync(scheduledPresentation);

            var addedPresentationMessage = new Domain.Models.Messages.Presentations.Added {
                PresentationId = savedScheduledPresentation.PresentationId
            };
            await _presentationScheduleAddedQueue.AddMessageAsync(addedPresentationMessage);

            return(savedScheduledPresentation);
        }