Esempio n. 1
0
        public Tuple <bool, string> Notify(int store, NotifyData notification)
        {
            if (ws is null)
            {
                return(new Tuple <bool, string>(true, "ws undefiened"));
            }
            LinkedList <string> users;

            if (!StoreSubscribers.TryGetValue(store, out users))
            {
                return(new Tuple <bool, string>(false, "There is No Subscribers for the Store"));
            }
            foreach (string username in users)
            {
                User user = UM.GetUser(username);
                //add notification's user
                notification.UserName = username;
                if (!user.LoggedStatus())
                {
                    user.AddMessage(notification);
                    //add message to db, thus user can get it later
                    if (!user.IsGuest)
                    {
                        DbManager.Instance.InsertUserNotification(AdapterCommunication.ConvertNotifyData(notification));
                    }
                }
                else
                {
                    ws.notify(username, notification);
                }
            }
            return(new Tuple <bool, string>(true, ""));
        }
Esempio n. 2
0
        public Tuple <bool, string> IsSubscribe(string username, int storeID)
        {
            LinkedList <string> users;

            if (!StoreSubscribers.TryGetValue(storeID, out users))
            {
                return(new Tuple <bool, string>(false, "There is No subscription for the Store"));
            }
            if (users.Contains(username))
            {
                return(new Tuple <bool, string>(true, "User Subscribed to this store"));
            }
            return(new Tuple <bool, string>(false, "User DO not Subscribed to this store"));
        }
Esempio n. 3
0
        public Tuple <bool, string> subscribe(string username, int storeID)
        {
            LinkedList <string> users;

            if (!StoreSubscribers.TryGetValue(storeID, out users))
            {
                users = new LinkedList <string>();
                users.AddFirst(username);
                StoreSubscribers.Add(storeID, users);
                return(new Tuple <bool, string>(true, ""));
            }
            if (users.Contains(username))
            {
                return(new Tuple <bool, string>(true, "User Already Subscribed to this store"));
            }
            users.AddFirst(username);
            StoreSubscribers[storeID] = users;
            return(new Tuple <bool, string>(true, ""));
        }
Esempio n. 4
0
 public bool RemoveSubscriptionStore(int storeID)
 {
     return(StoreSubscribers.Remove(storeID));
 }