public SickLeaveAccountingEmailNotificationActor( IEmailWithFixedRecipientNotification createdEmailNotificationConfig, IEmailWithFixedRecipientNotification prolongedEmailNotificationConfig, IEmailWithFixedRecipientNotification cancelledEmailNotificationConfig, IActorRef organizationActor) { this.createdEmailNotificationConfig = createdEmailNotificationConfig; this.prolongedEmailNotificationConfig = prolongedEmailNotificationConfig; this.cancelledEmailNotificationConfig = cancelledEmailNotificationConfig; this.organizationActor = organizationActor; Context.System.EventStream.Subscribe <CalendarEventCreated>(this.Self); Context.System.EventStream.Subscribe <CalendarEventChanged>(this.Self); }
private void SendNotification(CalendarEventChangedWithAdditionalData message, IEmailWithFixedRecipientNotification notificationConfiguration) { var templateExpressionContext = new Dictionary <string, string> { ["employee"] = message.Employee.Name, ["employeeId"] = message.Employee.EmployeeId, ["startDate"] = message.Event.Dates.StartDate.ToString("dd/MM/yyyy"), ["endDate"] = message.Event.Dates.EndDate.ToString("dd/MM/yyyy") }; templateExpressionContext = new DictionaryMerge().Perform( templateExpressionContext, message.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value)); var templateExpressionParser = new TemplateExpressionParser(); var sender = notificationConfiguration.NotificationSender; var recipient = notificationConfiguration.NotificationRecipient; var subject = templateExpressionParser.Parse(notificationConfiguration.Subject, templateExpressionContext); var body = templateExpressionParser.Parse(notificationConfiguration.Body, templateExpressionContext); Context.System.EventStream.Publish( new NotificationEventBusMessage( new EmailNotification(sender, new[] { recipient }, subject, body))); }