Example #1
0
 public int GetImageCommentsCount(string ticket, TransitImageCommentQueryOptions options)
 {
     using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
     {
         ISession session = DBlog.Data.Hibernate.Session.Current;
         CountQuery query = new CountQuery(session, typeof(DBlog.Data.ImageComment), "ImageComment");
         if (options != null) options.Apply(query);
         return query.Execute<int>();
     }
 }
Example #2
0
        public List<TransitImageComment> GetImageComments(string ticket, TransitImageCommentQueryOptions options)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;

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

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

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

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

                foreach (ImageComment obj in list)
                {
                    if (obj.Comment.Threads == null || obj.Comment.Threads.Count == 0)
                    {
                        result.Insert(0, new TransitImageComment(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 TransitImageComment(session, obj, ticket));
                                break;
                            }
                        }
                    }
                }

                return result;
            }
        }