Exemple #1
0
        public static IList <NotificationEntity> CreateInAppNotifications(EditionEntity edition, NotificationType notificationType, string recipients, string actorUserEmail)
        {
            if (WebConfigHelper.RemoveActorUserFromNotificationRecipients)
            {
                recipients = NotificationControllerHelper.RemoveCurrentUserFromRecipients(recipients, actorUserEmail);
            }

            if (string.IsNullOrWhiteSpace(recipients))
            {
                return(null);
            }

            var recipientList = recipients.Split(Utility.Constants.EmailAddressSeparator).ToList();
            var notifications = new List <NotificationEntity>();

            foreach (var recipient in recipientList)
            {
                var notification = new NotificationEntity
                {
                    NotificationType = notificationType,
                    ReceiverEmail    = recipient,
                    EventId          = edition.EventId,
                    EditionId        = edition.EditionId,
                    CreatedOn        = DateTime.Now,
                    Displayed        = false,
                    SentByEmail      = false
                };

                notifications.Add(notification);
            }

            return(notifications);
        }
Exemple #2
0
        public static string GetUpdatedFields(object currentEdition, object edition, object currentEditionTranslation, object editionTranslation, UpdateDisplayType displayType)
        {
            var updatedFields = NotificationControllerHelper.GetUpdatedFields(currentEdition, edition, "Edition", displayType);

            if (currentEditionTranslation != null && editionTranslation != null)
            {
                var updatedFieldsEditionTranslation = NotificationControllerHelper.GetUpdatedFields(currentEditionTranslation, editionTranslation, "EditionTranslation", displayType);
                if (displayType == UpdateDisplayType.Json) // TODO: Improve it (maybe using UpdatedFieldsDisplayType class?)
                {
                    if (!string.IsNullOrWhiteSpace(updatedFields))
                    {
                        updatedFields += ",";
                    }
                }
                updatedFields += updatedFieldsEditionTranslation;
            }

            return(updatedFields);
        }