public bool AddNotifications(IEnumerable <NewTicketPushNotificationInfo> infoItems)
        {
            var userSettings = SubscriberPushNotificationSettings.GetSettingsForUser("new ticket broadcast");

            foreach (var item in infoItems)
            {
                PushNotificationItems.AddRange(item.ToPushNotificationItems(userSettings));
            }
            return(true);
        }
        public bool AddNotifications(IEnumerable <TicketPushNotificationEventInfo> infoItems)
        {
            var appSettings = TicketDeskPushNotificationSettings;

            foreach (var item in infoItems)
            {
                var citem        = item; //foreach closure workaround
                var userSettings = SubscriberPushNotificationSettings.GetSettingsForUser(citem.SubscriberId);

                //get items already in db that haven't been sent yet
                var existingItems = TicketPushNotificationItems
                                    .Include(t => t.PushNotificationItem)
                                    .Include(t => t.PushNotificationItem.Destination)
                                    .Where(n =>
                                           n.PushNotificationItem.ContentSourceId == citem.TicketId &&
                                           n.PushNotificationItem.ContentSourceType == "ticket" &&
                                           n.PushNotificationItem.SubscriberId == citem.SubscriberId &&
                                           n.PushNotificationItem.DeliveryStatus == PushNotificationItemStatus.Scheduled);

                //for already scheduled, just add the new event
                foreach (var existingItem in existingItems)
                {
                    existingItem.AddNewEvent(citem, appSettings, userSettings);
                }

                //get note items for each destination
                var schedNotes = citem.ToPushNotificationItems(appSettings, userSettings);
                foreach (var schedNote in schedNotes)
                {
                    //if no item for this destination in existing scheduled items list, add a new note for that destination
                    if (existingItems.All(i => i.PushNotificationItem.DestinationId != schedNote.PushNotificationItem.DestinationId))
                    {
                        if (schedNote.TicketEventsList.Any())
                        {
                            //only add the new note if it contains an event... if only CanceledEvents exist
                            //  for new note, then the note came in pre-canceled by the sender. This happens
                            //  when the ticket event is marked as read from the start --usually when a
                            //  subscriber has initiated the event in the first place and anti-noise is set
                            //  to exclude subscriber's own events
                            TicketPushNotificationItems.Add(schedNote);
                        }
                    }
                }
            }
            return(true);
        }