Beispiel #1
0
        private void Subscribe(IObserver <string> responseObserver, string key)
        {
            CacheEntry cacheEntry;

            if (_cache.TryGet(key, out cacheEntry))
            {
                var notification = new StoreNotification
                {
                    Key       = key,
                    Data      = cacheEntry.Data,
                    EventId   = cacheEntry.EventId,
                    Expiry    = cacheEntry.Expiry,
                    Flags     = cacheEntry.Flags,
                    Operation = StoreOperation.Add
                };
                var combinedNotifications = Observable.Return(notification).Combine(_cache.Notifications); // TODO: must be a simpler way of doing this...

                _subscriptions[key] = combinedNotifications.
                                      OfType <IKeyCacheNotification>().
                                      Where(k => k.Key == key).
                                      Select(JsonFromNotifications).
                                      Subscribe(responseObserver);
            }
            else
            {
                _subscriptions[key] = _cache.Notifications.
                                      OfType <IKeyCacheNotification>().
                                      Where(k => k.Key == key).
                                      Select(JsonFromNotifications).
                                      Subscribe(responseObserver);
            }
        }
        public void setStoreNotificationStatusAsOld(int notificationID)
        {
            List <StoreNotification> nlist = context.StoreNotifications.Where(x => x.notificationID == notificationID).ToList();

            if (nlist.Count > 0)
            {
                StoreNotification notification = nlist.First();
                notification.status = "OLD";
                context.SaveChanges();
            }
        }
        public void addStoreNotification(string storeStaffID, string message, DateTime date)
        {
            StoreNotification notification = new StoreNotification();

            notification.storeStaffID = storeStaffID;
            notification.message      = message;
            notification.date         = date;
            notification.status       = "NEW";

            context.StoreNotifications.Add(notification);
            context.SaveChanges();
        }
Beispiel #4
0
 private static bool IsExpired(IScheduler scheduler, StoreNotification storeNotification, Dictionary <string, DateTime> updatedExpiry)
 {
     return(updatedExpiry.ContainsKey(storeNotification.Key) || storeNotification.Expiry > scheduler.Now);
 }
Beispiel #5
0
 public void NotifyCustomer(CustomerOrderDTO order)
 {
     StoreNotification.Notify(order, $"An employee has updated your oder with the status: {order.OrderStatus.Name}.");
 }
Beispiel #6
0
 public void NotifyEmployee(CustomerOrderDTO order)
 {
     StoreNotification.Notify(order, $"An order has a new status: {order.OrderStatus.Name}. Please review it.");
 }