/// <summary>
 /// since i know the datetime in wich the notification has been created,
 /// and i asked for the last status, i can flag as handled all the statusChange for the entity prior to the processed notification
 /// </summary>
 /// <param name="clientIdentifier"></param>
 /// <param name="Notification"></param>
 public void SetStatus(Guid clientIdentifier, DTONotification Notification)
 {
     using (var ctx = new OrmPendingNotifications())
     {
         var notificationsToFlag = ctx.NotificationToClient.Where(
             //-->Notifications not handled
             x => x.Status != PendingNotificationStatus.Handled
             //-->created before the date of the notification i want to flag
             && x.NotificationQueue.CreationDateTime <= Notification.CreationDateTime
             //For my client
             && x.ClientID == clientIdentifier
             //ofcourse for the same entity
             && x.NotificationQueue.NotificationDTOkey.Equals(Notification.Key) &&
             x.NotificationQueue.NotificationDTOType.Equals(Notification.NotificationDTOType));
         foreach (var t in notificationsToFlag)
         {
             t.Status           = Notification.Status;
             ctx.Entry(t).State = EntityState.Modified;
         }
         ctx.SaveChanges();
     }
 }
        public void AppendNotification(DTONotification notification)
        {
            notification.Status           = PendingNotificationStatus.Queued;
            notification.CreationDateTime = DateTime.UtcNow;
            var clients = getClientsForCurrentNotification(notification);

            if (clients == null || !clients.Any())
            {
                return;
            }

            //-->appendo la modifica
            var tabNotifica = new NotificationQueue
            {
                CreationDateTime    = DateTime.UtcNow,
                CreatorID           = notification.CreatorIdentifier,
                NotificationDTOType = notification.NotificationDTOType,
                NotificationDTOkey  = notification.Key,
                OperationType       = notification.NotificationType
            };



            using (var ctx = new OrmPendingNotifications())
            {
                ctx.NotificationQueue.Attach(tabNotifica);
                foreach (var cl in clients)
                {
                    var tabClient = new NotificationToClient();
                    tabClient.ClientID          = cl.ID;
                    tabClient.Status            = PendingNotificationStatus.Queued;
                    tabClient.NotificationID    = tabNotifica.ID;
                    tabClient.NotificationQueue = tabNotifica;
                    ctx.NotificationToClient.Add(tabClient);
                    //ctx.Entry(tabClient).State = EntityState.Added;
                }
                ctx.SaveChanges();
            }
        }