Exemple #1
0
        public async Task ShouldReturnAListOfLinkedEvents()
        {
            // Arrange
            var linkedEvent = new Event()
            {
                Slug = "event-slug"
            };
            var listOfLinkedEvents = new List <Event> {
                linkedEvent
            };
            var group = new ProcessedGroup()
            {
                Events = listOfLinkedEvents, Slug = "test"
            };

            // Mocks
            _processedRepository.Setup(o => o.Get <Group>(It.IsAny <string>(), It.IsAny <List <Query> >()))
            .ReturnsAsync(new StockportWebapp.Http.HttpResponse((int)HttpStatusCode.OK, group, string.Empty));
            _loggedInHelper.Setup(_ => _.GetLoggedInPerson()).Returns(new LoggedInPerson());

            _configuration.Setup(_ => _.GetArchiveEmailPeriods())
            .Returns(new List <ArchiveEmailPeriod> {
                new ArchiveEmailPeriod {
                    NumOfDays = 1
                }
            });

            // Act
            var view = await _groupController.Detail("slug") as ViewResult;

            var model = view.ViewData.Model as GroupDetailsViewModel;

            // Assert
            model.Group.Events.FirstOrDefault().Should().Be(linkedEvent);
        }
        public virtual void SendEmailDelete(ProcessedGroup group)
        {
            var messageSubject = $"Delete {group.Name}";

            _logger.LogInformation("Sending group delete email");

            var emailBody = new GroupDelete {
                Name = group.Name
            };

            var emailsTosend = string.Join(",", group.GroupAdministrators.Items.Select(i => i.Email).ToList());

            if (!string.IsNullOrEmpty(emailsTosend))
            {
                _emailClient.SendEmailToService(new EmailMessage(messageSubject, _emailClient.GenerateEmailBodyFromHtml(emailBody),
                                                                 _fromEmail, emailsTosend, new List <IFormFile>()));
            }
        }
        public virtual void SendEmailEventDelete(ProcessedEvents eventItem, ProcessedGroup group)
        {
            var messageSubject = $"Delete {eventItem.Title}";

            _logger.LogInformation("Sending event delete email");

            var emailBody = new EventDelete {
                Title = eventItem.Title
            };

            var emailsTosend = string.Join(",", group.GroupAdministrators.Items.Select(i => i.Email).ToList());

            emailsTosend = emailsTosend + "," +
                           _configuration.GetGroupSubmissionEmail(_businessId.ToString());

            if (!string.IsNullOrEmpty(emailsTosend))
            {
                _emailClient.SendEmailToService(new EmailMessage(messageSubject, _emailClient.GenerateEmailBodyFromHtml(emailBody),
                                                                 _fromEmail, emailsTosend, new List <IFormFile>()));
            }
        }