Ejemplo n.º 1
0
        public PostImageTest()
        {
            PostTest Post = new PostTest();
            AddDependentObject(Post);

            ImageTest image = new ImageTest();
            AddDependentObject(image);

            mPostImage = new PostImage();
            mPostImage.Image = image.Image;
            mPostImage.Post = Post.Post;
        }
Ejemplo n.º 2
0
 public TransitPostImage(ISession session, DBlog.Data.PostImage o, string ticket)
     : base(o.Id)
 {
     Post  = new TransitPost(session, o.Post, ticket);
     Image = new TransitImage(session, o.Image, ticket);
 }
Ejemplo n.º 3
0
        public int CreateOrUpdatePostImage(string ticket, int post_id, TransitImage t_image)
        {
            using (DBlog.Data.Hibernate.Session.OpenConnection(GetNewConnection()))
            {
                ISession session = DBlog.Data.Hibernate.Session.Current;
                CheckAdministrator(session, ticket);

                Post post = (Post)session.Load(typeof(Post), post_id);

                Image image = t_image.GetImage(session);
                image.Modified = DateTime.UtcNow;
                session.SaveOrUpdate(image);

                PostImage post_image = session.CreateCriteria(typeof(PostImage))
                    .Add(Expression.Eq("Post.Id", post_id))
                    .Add(Expression.Eq("Image.Id", t_image.Id))
                    .UniqueResult<PostImage>();

                if (post_image == null)
                {
                    post_image = new PostImage();
                    post_image.Post = post;
                    post_image.Image = image;
                    session.SaveOrUpdate(post_image);
                }

                session.Flush();
                return image.Id;
            }
        }