Пример #1
0
		/// <summary>
		/// Gets the thread subscription object for the thread - user combination passed in. If there's no subscription, null is returned.
		/// </summary>
		/// <param name="threadID">The thread ID.</param>
		/// <param name="userID">The user ID.</param>
		/// <param name="transactionToUse">The transaction to use. Pass in the transaction object if this fetch has to take place inside a transaction</param>
		/// <returns>
		/// requested Threadsubscription entity or null if not found
		/// </returns>
		public static ThreadSubscriptionEntity GetThreadSubscription(int threadID, int userID, Transaction transactionToUse)
		{
			ThreadSubscriptionEntity toReturn = new ThreadSubscriptionEntity();
			if(transactionToUse != null)
			{
				// transaction in progress, add entity to it so it's not blocked
				transactionToUse.Add(toReturn);
			}

			// fetch the data
			toReturn.FetchUsingPK(userID, threadID);
			if(toReturn.IsNew)
			{
				// not found
				return null;
			}

			// done. Don't commit a passed in transaction here, it's controlled by the caller.
			return toReturn;
		}
Пример #2
0
 /// <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;
 }
Пример #3
0
        /// <summary>Creates a new, empty ThreadSubscriptionEntity object.</summary>
        /// <returns>A new, empty ThreadSubscriptionEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new ThreadSubscriptionEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewThreadSubscription
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }