Ejemplo n.º 1
0
        private EditionMailTemplate GetEmailTemplateForEditionUpdateNotification(EditionEntity edition)
        {
            var recipients        = _eventDirectorServices.GetRecipientEmails(edition);
            var recipientFullName = _editionHelper.GetEventDirectorFullName(edition);
            var notificationAttr  = NotificationType.EditionLocationUpdated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
Ejemplo n.º 2
0
        private EditionMailTemplate GetEmailTemplateForEditionCreation(EditionEntity edition)
        {
            var recipients        = WebConfigHelper.NewEventNotificationRecipients;
            var recipientFullName = "";
            var notificationAttr  = NotificationType.EditionCreated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
        /* NOTIFICATION - COMMON */
        protected void PushEditionUpdateNotifications(EditionEntity edition, string updatedFields)
        {
            if (WebConfigHelper.TrackEditionUpdate && !string.IsNullOrWhiteSpace(updatedFields))
            {
                var subscribers = GetSubscriberEmails(edition.EditionId);
                var inAppNotificationRecipients = subscribers;
                var emailRecipients             = WebConfigHelper.TrackEditionUpdateUseMockRecipients
                    ? WebConfigHelper.AdminEmails
                    : subscribers;

                var body = $"Field(s) updated by {CurrentCedUser.CurrentUser.FullName} on {edition.UpdateTime}:<br/><br/>";
                body += updatedFields;

                const NotificationType notificationType = NotificationType.EditionUpdated;
                var notifAttr         = notificationType.GetAttribute <NotificationAttribute>();
                var buttonUrl         = _editionHelper.GetEditionUrl(edition);
                var unsubscriptionUrl = notifAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;

                CreateInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                PushRealTimeInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                var emailResult = SendEmailNotification(edition, notificationType, emailRecipients, CurrentCedUser.CurrentUser, body,
                                                        buttonUrl, unsubscriptionUrl);

                // STEP 5: LOG EMAIL
                if (emailResult.Sent)
                {
                    LogEmail(edition.EditionId, inAppNotificationRecipients, body, CurrentCedUser.CurrentUser.Email, notificationType.ToString());
                }
                else
                {
                    LogEmail(edition.EditionId, WebConfigHelper.AdminEmails, emailResult.ErrorMessage, null, notificationType.ToString());
                }
            }
        }