Beispiel #1
0
        private static int GetOrCreateDiscussionId(
            ISession session,
            int accountid,
            Type type,
            int objectid,
            ManagedSecurityContext sec)
        {
            Discussion d = Find(session, accountid, type, objectid, sec);

            if (d != null)
            {
                return(d.Id);
            }

            ManagedDiscussionMapEntry mapentry = ManagedDiscussionMap.Find(type);

            TransitDiscussion td = new TransitDiscussion();

            td.AccountId    = accountid;
            td.Name         = mapentry.Name;
            td.Personal     = true;
            td.Description  = string.Empty;
            td.Created      = td.Modified = DateTime.UtcNow;
            td.ObjectId     = objectid;
            td.DataObjectId = ManagedDataObject.Find(session, type);

            // creating a discussion that belongs to a different user (commenting on someone's items)
            ManagedDiscussion      m_d   = new ManagedDiscussion(session);
            ManagedSecurityContext o_sec = new ManagedSecurityContext(session, accountid);

            return(m_d.CreateOrUpdate(td, o_sec));
        }