Beispiel #1
0
        private List <int?> GetStartDateDifferencesByPreviousEdition(EditionEntity edition)
        {
            var previousEdition = _editionServices.GetPreviousEdition(edition, Utility.Constants.ValidEventTypesForCed);

            if (previousEdition == null)
            {
                return new List <int?> {
                           null, null
                }
            }
            ;
            var weekDiff = previousEdition.StartDate.GetValueOrDefault().WeekOfYearDiff(edition.StartDate.GetValueOrDefault());
            var dayDiff  = previousEdition.StartDate.GetValueOrDefault().DayOfYearDiff(edition.StartDate.GetValueOrDefault());

            return(new List <int?> {
                weekDiff, dayDiff
            });
        }
Beispiel #2
0
        private void AddEditionsToNotificationList(IList <EmailNotificationListItemModel> notifications, IList <EditionEntity> editions, NotificationType notificationType, int checkDay)
        {
            foreach (var edition in editions)
            {
                EditionEntity prevEdition = null;
                var           sendingDate = DateTime.MinValue;

                switch (notificationType)
                {
                case NotificationType.EditionExistence:     // TODO:???
                    break;

                case NotificationType.GeneralInfoCompleteness:
                    prevEdition = EditionServices.GetPreviousEdition(edition);
                    sendingDate = prevEdition.StartDate.Value.AddDays(-checkDay);
                    break;

                case NotificationType.PostShowMetricsInfoCompleteness:
                case NotificationType.PostShowMetricsInfoCompleteness2:
                    sendingDate = edition.EndDate.Value.AddDays(checkDay);
                    break;
                }

                var log = NotificationEmailSent(prevEdition ?? edition, notificationType, sendingDate);

                notifications.Add(new EmailNotificationListItemModel
                {
                    EmailSendingDate = sendingDate,
                    NotificationType = notificationType,
                    EditionName      = edition.EditionName,
                    StartDate        = edition.StartDate.GetValueOrDefault(),
                    EndDate          = edition.EndDate.GetValueOrDefault(),
                    ReceiverEmail    = log?.AdditionalInfo.Substring("Recipient: ".Length, log.AdditionalInfo.IndexOf("|") - "Recipient: ".Length),
                    SentByEmail      = log != null,
                    CreatedOn        = log?.CreatedOn
                });
            }
        }