private PushNotification CreatePushNotification( string employeeId, CalendarEvent @event, IEnumerable <DevicePushToken> deviceTokens) { var templateExpressionContext = new Dictionary <string, string> { ["startDate"] = @event.Dates.StartDate.ToString("dd/MM/yyyy"), ["endDate"] = @event.Dates.EndDate.ToString("dd/MM/yyyy") }; templateExpressionContext = new DictionaryMerge().Perform( templateExpressionContext, @event.AdditionalData.ToDictionary(x => x.Key, x => x.Value)); var content = new PushNotificationContent { Title = this.reminderConfiguration.ReminderPush.Title, Body = new TemplateExpressionParser().Parse(this.reminderConfiguration.ReminderPush.Body, templateExpressionContext), CustomData = new { @event.EventId, EmployeeId = employeeId, Type = VacationReminderPushNotificationType } }; return(new PushNotification(content, deviceTokens.ToList())); }
private EmailNotification CreateEmailNotification(CalendarEvent @event, EmployeeMetadata employeeMetadata) { var templateExpressionContext = new Dictionary <string, string> { ["startDate"] = @event.Dates.StartDate.ToString("dd/MM/yyyy"), ["endDate"] = @event.Dates.EndDate.ToString("dd/MM/yyyy") }; templateExpressionContext = new DictionaryMerge().Perform( templateExpressionContext, @event.AdditionalData.ToDictionary(x => x.Key, x => x.Value)); var sender = this.reminderConfiguration.ReminderEmail.NotificationSender; var recipient = employeeMetadata.Email; var subject = this.reminderConfiguration.ReminderEmail.Subject; var body = new TemplateExpressionParser().Parse(this.reminderConfiguration.ReminderEmail.Body, templateExpressionContext); return(new EmailNotification(sender, new[] { recipient }, subject, body)); }