public void CanGetListOfPersonEventsForAGroup() { var eventRepository = MockRepository.GenerateStub<IEventRepository>(); var eventList = new List<PersonEventDto> { new PersonEventDto(), new PersonEventDto(), new PersonEventDto() }; var currentPerson = new Person {Permissions = new List<int> {57}}; eventRepository .Expect(e => e.GetPersonEventsForGroup(1, currentPerson)) .Return(eventList); var permissionRepository = new PermissionRepository(); var personRepository = new PersonRepository(permissionRepository, new ChurchRepository()); var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var groupRepository = new GroupRepository(); var messageRepository = new MessageRepository(); var messageRecepientRepository = new MessageRecepientRepository(); var messageAttachmentRepository = new MessageAttachmentRepository(); var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository); var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository(); var emailContentRepository = new EmailContentRepository(); var emailContentService = new EmailContentService(emailContentRepository); var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository); IEventService eventService = new EventService(eventRepository, emailService, new BirthdayAndAniversaryRepository()); var sut = eventService.GetPersonEventsForGroup(1, currentPerson); Assert.That(sut.Count(), Is.EqualTo(3)); }
public AjaxController() { var messageRepository = new MessageRepository(); var permissionRepository = new PermissionRepository(); var churchRepository = new ChurchRepository(); var personRepository = new PersonRepository(permissionRepository, churchRepository); var uploadPhotoRepository = new PhotoRepository(); _familyRepository = new FamilyRepository(uploadPhotoRepository); _usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var personGroupRepository = new PersonGroupRepository(personRepository); _personGroupRepository = personGroupRepository; var groupRepository = new GroupRepository(); var emailSender = new EmailSender(messageRepository, new MessageRecepientRepository(), new MessageAttachmentRepository(), personRepository); var emailContentService = new EmailContentService(new EmailContentRepository()); var churchEmailTemplateRepository = new ChurchEmailTemplatesRepository(); _emailService = new EmailService( _usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplateRepository, permissionRepository ); _passwordService = new PasswordService(personRepository, churchRepository, _usernamePasswordRepository, _emailService); _personService = new PersonService( personRepository, _personGroupRepository, permissionRepository, new PersonRoleRepository(), new PersonOptionalFieldRepository(), new RelationshipRepository(personRepository), new ChurchMatcherRepository(), groupRepository, _familyRepository, _emailService, new AddressRepository(), uploadPhotoRepository ); _groupEventRepository = new GroupEventRepository(personRepository); _systemAdministratorService = new SystemAdministratorService(churchRepository, permissionRepository); _personGroupService = new PersonGroupService(_personGroupRepository); _messageRecepientRepository = new MessageRecepientRepository(); var httpPostService = new HttpPostService(); _smsSender = new SmsSender(messageRepository, new MessageRecepientRepository(), personRepository, httpPostService); _churchEventsReporitory = new ChurchEventsRepository(); _messageService = new MessageService(_messageRecepientRepository); var birthdayRepository = new BirthdayAndAniversaryRepository(); var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository(); var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository); var eventRepository = new EventRepository(birthdayRepository); _eventService = new EventService(eventRepository, emailService, birthdayRepository); _childReportsService = new ChildReportsService(new ChildrenReportsRepository(), _emailService); _reminderService = new ReminderService(new ReminderRepository()); }
public GroupEventsController() { var birthdayRepository = new BirthdayAndAniversaryRepository(); var permissionRepository = new PermissionRepository(); var personRepository = new PersonRepository(permissionRepository, new ChurchRepository()); var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var groupRepository = new GroupRepository(); var messageRepository = new MessageRepository(); var messageRecepientRepository = new MessageRecepientRepository(); var messageAttachmentRepository = new MessageAttachmentRepository(); var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository); var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository(); var emailContentRepository = new EmailContentRepository(); var emailContentService = new EmailContentService(emailContentRepository); var emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository); var eventRepository = new EventRepository(birthdayRepository); _eventService = new EventService(eventRepository, emailService, birthdayRepository); }
public EmailController() { var permissionRepository = new PermissionRepository(); var personRepository = new PersonRepository(permissionRepository, new ChurchRepository()); var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var groupRepository = new GroupRepository(); _messageRecepientRepository = new MessageRecepientRepository(); var emailSender = new EmailSender(new MessageRepository(), _messageRecepientRepository, new MessageAttachmentRepository(), personRepository); var emailContentService = new EmailContentService(new EmailContentRepository()); var churchEmailTemplateRepository = new ChurchEmailTemplatesRepository(); _emailService = new EmailService( usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplateRepository, permissionRepository ); }
public HomeController() { var permissionRepository = new PermissionRepository(); var churchRepository = new ChurchRepository(); _personRepository = new PersonRepository(permissionRepository, churchRepository); var birthdayRepository = new BirthdayAndAniversaryRepository(); var personRepository = new PersonRepository(permissionRepository, new ChurchRepository()); var usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); var groupRepository = new GroupRepository(); var messageRepository = new MessageRepository(); var messageRecepientRepository = new MessageRecepientRepository(); var messageAttachmentRepository = new MessageAttachmentRepository(); var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository); var churchEmailTemplatesRepository = new ChurchEmailTemplatesRepository(); var emailContentRepository = new EmailContentRepository(); var emailContentService = new EmailContentService(emailContentRepository); _emailService = new EmailService(usernamePasswordRepository, personRepository, groupRepository, emailSender, emailContentService, churchEmailTemplatesRepository, permissionRepository); var eventRepository = new EventRepository(birthdayRepository); _eventService = new EventService(eventRepository, _emailService, birthdayRepository); _personGroupRepository = new PersonGroupRepository(_personRepository); _usernamePasswordRepository = new UsernamePasswordRepository(permissionRepository); _photoRepository = new PhotoRepository(); _photoServices = new PhotoServices(); _personService = new PersonService( _personRepository, new PersonGroupRepository(_personRepository), permissionRepository, new PersonRoleRepository(), new PersonOptionalFieldRepository(), new RelationshipRepository(_personRepository), new ChurchMatcherRepository(), new GroupRepository(), new FamilyRepository(_photoRepository), _emailService, new AddressRepository(), _photoRepository ); }
public RemindersController() { _reminderService = new ReminderService(new ReminderRepository()); var permissionRepository = new PermissionRepository(); _churchRepository = new ChurchRepository(); var personRepository = new PersonRepository(permissionRepository, _churchRepository); _birthdayAndAnniversaryService = new BirthdayAndAnniversaryService(new BirthdayAndAniversaryRepository()); _emailSender = new EmailSender(new MessageRepository(), new MessageRecepientRepository(), new MessageAttachmentRepository(), personRepository); _monthNames = new Dictionary<int, string> { {1, "January"}, {2, "February"}, {3, "March"}, {4, "April"}, {5, "May"}, {6, "June"}, {7, "July"}, {8, "August"}, {9, "September"}, {10, "October"}, {11, "November"}, {12, "December"} }; }
public IEnumerable<string> Get() { var returnMessages = new List<string>(); using (var pop3Client = new Pop3Client()) { var messages = GetNewMessages(pop3Client); var messageCount = messages.Count(); if (messageCount > 0) { IMessageRepository messageRepository = new MessageRepository(); IMessageRecepientRepository messageRecepientRepository = new MessageRecepientRepository(); IMessageAttachmentRepository messageAttachmentRepository = new MessageAttachmentRepository(); IPermissionRepository permissionRepository = new PermissionRepository(); IChurchRepository churchRepository = new ChurchRepository(); IPersonRepository personRepository = new PersonRepository(permissionRepository, churchRepository); var emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository); foreach (var m in messages) { var mm = m.Value.ToMailMessage(); var regex = new Regex(@"##([0-9]*)##"); var matches = regex.Matches(mm.Body); if (matches.Count > 0 && matches[0].Groups.Count > 1) { try { int messageId; if (int.TryParse(matches[0].Groups[1].Value, out messageId)) { var originalSender = messageRepository.GetSender(messageId); if (originalSender != null) { var originalReceiver = personRepository.FetchPersonIdsFromEmailAddress(mm.From.Address, originalSender.ChurchId); var fromPersonId = originalSender.PersonId; if (originalReceiver.Any()) { fromPersonId = originalReceiver.First(); } returnMessages.Add(string.Format("Forwarding email on to {0}", originalSender.Email)); emailSender.SendEmail(mm.Subject, mm.Body, Username, originalSender.Email, Username, Password, fromPersonId, originalSender.ChurchId, mm.Attachments); } if (!DeleteMessageByMessageId(pop3Client, m.Key)) { var exception = new Exception("Cannot delete message " + mm.Subject + " " + mm.From); emailSender.SendExceptionEmailAsync(exception); } //pop3Client.DeleteMessage(count + 1); } } catch (Exception errSending) { returnMessages.Add(errSending.Message); emailSender.SendExceptionEmailAsync(errSending); } } } } } return returnMessages; }
public string GetEmails() { var returnMessages = new List<string>(); using (var pop3Client = new Pop3Client()) { var messages = GetNewMessages(pop3Client); var messageCount = messages.Count(); if (messageCount > 0) { IMessageRepository messageRepository = new MessageRepository(); IMessageRecepientRepository messageRecepientRepository = new MessageRecepientRepository(); IMessageAttachmentRepository messageAttachmentRepository = new MessageAttachmentRepository(); IPermissionRepository permissionRepository = new PermissionRepository(); IChurchRepository churchRepository = new ChurchRepository(); IPersonRepository personRepository = new PersonRepository(permissionRepository, churchRepository); IEmailSender emailSender = new EmailSender(messageRepository, messageRecepientRepository, messageAttachmentRepository, personRepository); for (var count = 0; count < messageCount; count++) { var mm = messages[count].ToMailMessage(); var regex = new Regex(@"##([0-9]*)##"); var matches = regex.Matches(mm.Body); if (matches.Count > 0 && matches[0].Groups.Count > 1) { try { int messageId; if (int.TryParse(matches[0].Groups[1].Value, out messageId)) { var originalSender = messageRepository.GetSender(messageId); if (originalSender != null) { var originalReceiver = personRepository.FetchPersonIdsFromEmailAddress(mm.From.Address, originalSender.ChurchId); var fromPersonId = originalSender.PersonId; if (originalReceiver.Any()) { fromPersonId = originalReceiver.First(); } returnMessages.Add(string.Format("Forwarding reply from {0} for messageId {1} on to {2}", fromPersonId, messageId, originalSender.Email)); emailSender.SendEmail(mm.Subject, mm.Body, Username, originalSender.Email, Username, Password, fromPersonId, originalSender.ChurchId, mm.Attachments); } pop3Client.DeleteMessage(count + 1); } } catch (Exception errSending) { returnMessages.Add(errSending.Message); emailSender.SendExceptionEmailAsync(errSending); } } } } } if (!returnMessages.Any()) { return "No replies found"; } var returnMessage = returnMessages.Aggregate(string.Empty, (current, m) => current + (m + "<br/>")); _emailService.SendSystemEmail("Replies found", returnMessage); return returnMessage; }