Ejemplo n.º 1
0
 public int GetPostCommentsCount(string ticket, TransitPostCommentQueryOptions options)
 {
     using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
     {
         ISession session = DBlog.Data.Hibernate.Session.Current;
         CountQuery query = new CountQuery(session, typeof(DBlog.Data.PostComment), "PostComment");
         if (options != null) options.Apply(query);
         return query.Execute<int>();
     }
 }
Ejemplo n.º 2
0
        public List<TransitPostComment> GetPostComments(string ticket, TransitPostCommentQueryOptions options)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;

                ICriteria cr = session.CreateCriteria(typeof(PostComment));

                if (options != null)
                {
                    options.Apply(cr);
                }

                IList<PostComment> list = cr.List<PostComment>();

                List<TransitPostComment> result = new List<TransitPostComment>(list.Count);

                foreach (PostComment obj in list)
                {
                    if (obj.Comment.Threads == null || obj.Comment.Threads.Count == 0)
                    {
                        result.Insert(0, new TransitPostComment(session, obj, ticket));
                    }
                    else
                    {
                        for (int i = 0; i < result.Count; i++)
                        {
                            if (result[i].CommentId == ((Thread)obj.Comment.Threads[0]).ParentComment.Id)
                            {
                                result.Insert(i + 1, new TransitPostComment(session, obj, ticket));
                                break;
                            }
                        }
                    }
                }

                return result;
            }
        }