Exemple #1
0
        public void SendmailForJob(string subscriber, string subject, string title)
        {
            var allItems = new List <Models.NotificationEntry>();

            GetItemsFromNotificationGroup(allItems, subscriber);

            var items = DBContext.NotificationEntries.Where(n =>
                                                            n.NotificationType == NotificationType &&
                                                            n.SubscriptionID == subscriber
                                                            );

            allItems.AddRange(items);

            items = allItems.AsQueryable()
                    .OrderBy(n => n.Duedate)
                    .ThenBy(n => n.Startdate)
                    .ThenBy(n => n.Enddate);

            if (items.Any())
            {
                Logger.LogDebug($"Found {items.Count()} {NotificationType} items for subscriber {subscriber}.");

                INotificationFormatter formatter = new NotificationMailFormatter
                {
                    Template   = MailTemplate,
                    TableTitle = title,
                    Salutation = items.First(n => !string.IsNullOrEmpty(n.Salutation))?.Salutation ?? "team member"
                };

                var message = formatter.FormatMessage(items.ToList());

                Transmitter.Recipient = subscriber;
                Transmitter.Transmit(subject, message);
            }
            else
            {
                Logger.LogInformation($"No {NotificationType} items for subscriber {subscriber}.");
            }
        }
 public void SendMessage(string testMessage) =>
 messageTransmitter.Transmit(testMessage);