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, "")); }
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")); }
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, "")); }