Esempio n. 1
0
 public async Task Handle(NotificationMessage message, RecipientContactInfo recipient)
 {
     if (message.Subject != null && message.Body != null)
     {
         _repo.AddNotification(new Notification(message.NotificationEvent, recipient.UserId, message.Subject,
                                                message.Body));
         await _unitOfWork.SaveAsync(default);
Esempio n. 2
0
        public void ConstructorWithUserIdAndEmail_WhenCalled_SetPropertiesCorrectly()
        {
            _sut = new RecipientContactInfo("userId", "email");

            Assert.That(_sut.UserId, Is.EqualTo("userId"));
            Assert.That(_sut.Email, Is.EqualTo("email"));
        }
        public async Task Handle(UserSigningUpCompletedEventNotification @event, CancellationToken token)
        {
            var recipient = new RecipientContactInfo(null, @event.User.Email);
            var userInfo  = new UserInfo(@event.User.UserName);

            await _notificationHandler.Handle(recipient, UserSigningUpCompletedEvent.Instance, userInfo);
        }
        public async Task Handle(SigningUpInitializedEvent @event, CancellationToken token)
        {
            var recipient    = new RecipientContactInfo(null, @event.SigningUp.Email);
            var signingUpIfo = new SigningUpInfo(GetLinkToCompleteSigningUp(@event.SigningUp.Token));

            await _notificationHandler.Handle(recipient, OrganizationSigningUpInitializedEvent.Instance,
                                              signingUpIfo);
        }
        public async Task Handle(PasswordTokenSetEvent @event, CancellationToken token)
        {
            var recipient         = new RecipientContactInfo(@event.User.Id, @event.User.Email);
            var resetPasswordInfo = new ResetPasswordInfo(GetLinkToResetPassword(@event.User.PasswordToken));

            await _notificationHandler.Handle(recipient, PasswordForgottenEvent.Instance,
                                              resetPasswordInfo);
        }
Esempio n. 6
0
        public async Task Handle(MembersInvitedEvent @event, CancellationToken token)
        {
            foreach (var user in @event.Users)
            {
                var recipient     = new RecipientContactInfo(null, user.Email);
                var signingUpInfo = new SigningUpInfo(user.InvitedBy, GetLinkToCompleteSigningUp(user.InvitationToken));

                await _notificationHandler.Handle(recipient, UserSigningUpInitializedEvent.Instance,
                                                  signingUpInfo);
            }
        }
        public async Task Handle(RecipientContactInfo recipient, NotificationEvent @event, NotificationData data = null)
        {
            var excludedTemplates = _repo.GetDisabledNotifications(_currentUserAccessor.OrganizationId);

            var templates = _repo.GetNotificationTemplatesByNotificationEvent(@event, excludedTemplates);

            foreach (var template in templates)
            {
                var message = _messageGenerator.Generate(template, data);
                await _messageDispatcher.Dispatch(template.Type, message, recipient);
            }
        }
 public async Task Dispatch(NotificationType notificationType, NotificationMessage message, RecipientContactInfo recipient)
 {
     foreach (var notificationSender in _notificationSenders)
     {
         if (notificationSender.NotificationType.Name == notificationType.Name)
         {
             await notificationSender.Handle(message, recipient);
         }
     }
 }
 public async Task Handle(NotificationMessage message, RecipientContactInfo recipient)
 {
     var email = new Email(recipient.Email, message.Subject, message.Body);
     await _emailSender.SendEmailAsync(email);
 }