/// <summary> /// Unsubscribes the specified user from the specified thread. /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="userID">The user ID.</param> /// <returns>true if delete succeeded, false otherwise</returns> public static bool RemoveSingleSubscription(int threadID, int userID) { ThreadSubscriptionEntity subscription = ThreadGuiHelper.GetThreadSubscription(threadID, userID); if (subscription != null) { // there's a subscription, delete it return(subscription.Delete()); } else { return(true); } }
/// <summary> /// Subscribes the user specified to the thread specified for notifications. A transaction can be specified to save the information inside the /// transaction specified. If the user is already subscribed to this thread, nothing is done /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="userID">The user ID.</param> /// <param name="transactionToUse">The transaction to use. If no transaction is specified, no transaction is created</param> /// <returns></returns> public static bool AddThreadToSubscriptions(int threadID, int userID, Transaction transactionToUse) { // check if this user is already subscribed to this thread. If not, add a new subscription. ThreadSubscriptionEntity subscription = ThreadGuiHelper.GetThreadSubscription(threadID, userID, transactionToUse); if (subscription == null) { // user isn't yet subscribed, add the subscription subscription = new ThreadSubscriptionEntity(); subscription.UserID = userID; subscription.ThreadID = threadID; if (transactionToUse != null) { transactionToUse.Add(subscription); } return(subscription.Save()); } // already subscribed, no-op. return(true); }
/// <summary> /// Checks if thread is already subscribed. If so, true is returned otherwise false. /// </summary> /// <param name="userID">The user ID.</param> /// <param name="threadID">The thread ID.</param> /// <returns>true if the user is already subscribed to this thread otherwise false</returns> public static bool CheckIfThreadIsAlreadySubscribed(int userID, int threadID) { return(ThreadGuiHelper.GetThreadSubscription(threadID, userID) != null); }