private PushNotification CreatePushNotification(CalendarEventApprovalsChangedWithAdditionalData message) { var templateExpressionContext = new Dictionary <string, string> { ["eventType"] = message.Event.Type, ["approver"] = message.Approver.Name }; 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, ApproverId = message.Approver.EmployeeId, Type = CalendarEventPushNotificationTypes.EventUserGrantedApproval } }; return(new PushNotification(content, message.OwnerPushTokens.ToList())); }
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 void SendNotification(CalendarEventWithAdditionalData message, IPushNotification notificationConfiguration) { var templateExpressionContext = new Dictionary <string, string> { ["employee"] = message.Owner.Name, ["startDate"] = message.Event.Dates.StartDate.ToString("dd/MM/yyyy") }; templateExpressionContext = new DictionaryMerge().Perform( templateExpressionContext, message.Event.AdditionalData.ToDictionary(x => x.Key, x => x.Value)); var content = new PushNotificationContent { Title = notificationConfiguration.Title, Body = new TemplateExpressionParser().Parse(notificationConfiguration.Body, templateExpressionContext), CustomData = new { message.Event.EventId, message.Owner.EmployeeId, ManagerId = message.Manager.EmployeeId, Type = message.NotificationType == NotificationType.Created ? CalendarEventPushNotificationTypes.SickLeaveCreatedManager : message.NotificationType == NotificationType.Prolonged ? CalendarEventPushNotificationTypes.SickLeaveProlongedManager : CalendarEventPushNotificationTypes.SickLeaveCancelledManager } }; Context.System.EventStream.Publish(new NotificationEventBusMessage( new PushNotification(content, message.ManagerPushTokens))); }
private PushNotification CreatePushNotification(IEnumerable <DevicePushToken> pushTokens) { var content = new PushNotificationContent { Title = this.updateNotificationSettings.NotificationTitle, Body = this.updateNotificationSettings.NotificationBody, CustomData = new PushNotificationContent.ContentCustomData { Type = UpdateAvailablePushNotificationType } }; return(new PushNotification(content, pushTokens)); }