Example #1
0
        public virtual void UpdateAtachments(long[] arrAttachmentIds, ContentPost post)
        {
            if (post == null || arrAttachmentIds.Length == 0)
            {
                return;
            }

            foreach (int id in arrAttachmentIds)
            {
                ContentAttachment a = ContentAttachment.findById(id);
                if (a == null)
                {
                    continue;
                }

                a.OwnerId    = post.OwnerId;
                a.OwnerType  = post.OwnerType;
                a.OwnerUrl   = post.OwnerUrl;
                a.Creator    = post.Creator;
                a.CreatorUrl = post.CreatorUrl;

                a.PostId = post.Id;
                a.AppId  = post.AppId;

                a.update();
            }

            int count = ContentAttachment.count("PostId=" + post.Id);

            post.Attachments = count;
            post.update();
        }
Example #2
0
        private static void refreshAttachmentCount(ContentAttachment at)
        {
            ContentPost post = ContentPost.findById(at.PostId);

            if (post == null)
            {
                return;
            }
            int count = ContentAttachment.count("PostId=" + post.Id);

            post.Attachments = count;
            post.update();
        }