private PushNotification CreatePushNotification(CalendarEventChangedWithAdditionalData message) { var templateExpressionContext = new Dictionary <string, string> { ["eventType"] = message.Event.Type, ["eventStatus"] = message.Event.Status }; templateExpressionContext = new DictionaryMerge().Perform( templateExpressionContext, message.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value)); var content = new PushNotificationContent { Title = this.pushNotificationConfig.Title, Body = new TemplateExpressionParser().Parse(this.pushNotificationConfig.Body, templateExpressionContext), CustomData = new { message.Event.EventId, message.Event.EmployeeId, Type = CalendarEventPushNotificationTypes.EventStatusChanged } }; return(new PushNotification(content, message.OwnerPushTokens.ToList())); }
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))); }