public void ReadNotification(int id)
        {
            Notification1 n = db.Notifications.Find(id);

            n.IsRead = true;
            db.SaveChangesAsync();
        }
Example #2
0
        public async Task SendNotificationAsync_SendsToAllBufferedChannels()
        {
            Notification1 n1 = new Notification1();
            await sut.PushNotificationAsync(n1);

            bufferedChannel1.Received(1).SendNotificationsAsync(
                Arg.Is <IEnumerable <INotification> >(x => x.Count() == 1 && x.First() == n1));
            bufferedChannel2.Received(1).SendNotificationsAsync(
                Arg.Is <IEnumerable <INotification> >(x => x.Count() == 1 && x.First() == n1));
        }
Example #3
0
        public async Task PushNotifications_SendsToCorrectChannels()
        {
            Notification1 n1First  = new Notification1();
            Notification1 n1Second = new Notification1();
            Notification2 n2       = new Notification2();
            await sut.PushNotifications(new INotification[] { n1First, n2, n1Second });

            notificationChannel1.Received(1).PushNotificationAsync(n1First);
            notificationChannel1.Received(1).PushNotificationAsync(n1Second);
            notificationChannel2.Received(1).PushNotificationAsync(n2);
        }
Example #4
0
        public async Task PushNotification_SendsToCorrectChannels()
        {
            Notification1 n1 = new Notification1();
            Notification2 n2 = new Notification2();
            await sut.PushNotification(n1);

            await sut.PushNotification(n2);

            notificationChannel1.Received(1).PushNotificationAsync(n1);
            notificationChannel2.Received(1).PushNotificationAsync(n2);
        }
        public async Task SendNotificationAsync_SavesNotificationToBuffer()
        {
            Notification1          n1       = new Notification1();
            Guid                   bufferId = Guid.NewGuid();
            SerializedNotification serializedNotification = new SerializedNotification()
            {
                NotificationClassName = "Notification1",
                NotificationJson      = "{}"
            };

            notificationSerializer.ToJson(n1).Returns(serializedNotification);
            bufferSelector.SelectBufferIdAsync(n1).Returns(bufferId);

            await sut.PushNotificationAsync(n1);

            bufferedNotificationStore.Received(1)
            .Add(serializedNotification, bufferId, FakeClock.Now, bufferGovernor.Id,
                 notificationPipeline.Id);
        }
        public List <Notification1> GetNotifications(int itemId)
        {
            try
            {
                List <Notification1> resultList = new List <Notification1>();

                IndustrialMonitoringEntities entities = new IndustrialMonitoringEntities();

                List <NotificationItem> notificationItems = entities.NotificationItems.Where(x => x.ItemId == itemId).ToList();

                if (notificationItems == null || notificationItems.Count == 0)
                {
                    return(null);
                }

                foreach (var notificationItem in notificationItems)
                {
                    NotificationItemsLogLatest notificationItemsLogLatest =
                        entities.NotificationItemsLogLatests.FirstOrDefault(
                            x => x.NotificationId == notificationItem.NotificationId);

                    if (notificationItemsLogLatest.Value)
                    {
                        Notification1 notification1 = new Notification1(notificationItem);
                        resultList.Add(notification1);
                    }
                }

                return(resultList);
            }
            catch (Exception ex)
            {
                Logger.LogMonitoringServiceLibrary(ex);
                return(null);
            }
        }