Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public static IList <MadLibInstance> GetMadLibs(ISession session, string table, int id)
 {
     return(session.CreateCriteria(typeof(MadLibInstance))
            .Add(Expression.Eq("DataObject.Id", ManagedDataObject.Find(session, table)))
            .Add(Expression.Eq("ObjectId", id))
            .List <MadLibInstance>());
 }
Ejemplo n.º 3
0
 public static IList <Feature> GetFeatures(ISession session, string table, int id)
 {
     return(session.CreateCriteria(typeof(Feature))
            .Add(Expression.Eq("DataObject.Id", ManagedDataObject.Find(session, table)))
            .Add(Expression.Eq("DataRowId", id))
            .List <Feature>());
 }
Ejemplo n.º 4
0
 public static int Delete(ISession session, string table, int id)
 {
     return(session.Delete(string.Format("from Feature f where f.DataObject.Id = {0} AND f.DataRowId = {1}",
                                         ManagedDataObject.Find(session, table), id)));
 }
Ejemplo n.º 5
0
 public static int GetLatestFeatureId(ISession session, string objectname, int rowid)
 {
     return(GetLatestFeatureId(session, ManagedDataObject.Find(session, objectname), rowid));
 }