示例#1
0
        public async Task RemoveAsync(int postId, PostImageType postImageType)
        {
            var postImages = await _context.PostImages.Where(x => x.PostId == postId && x.PostImageType == postImageType).ToListAsync();

            foreach (var postImage in postImages)
            {
                _context.PostImages.Remove(postImage);
            }

            await _context.SaveChangesAsync();
        }
示例#2
0
        public void Remove(int postId, PostImageType postImageType)
        {
            var postImages = _context.PostImages.Where(x => x.PostId == postId && x.PostImageType == postImageType);

            foreach (var postImage in postImages)
            {
                _context.PostImages.Remove(postImage);
            }

            _context.SaveChanges();
        }
示例#3
0
        public async Task AddAsync(int postId, int imageId, PostImageType postImageType)
        {
            var postImage = new PostImage
            {
                PostId        = postId,
                PostImageType = postImageType,
                ImageId       = imageId
            };

            _context.PostImages.Add(postImage);

            await _context.SaveChangesAsync();
        }
示例#4
0
        public void Add(int postId, int imageId, PostImageType postImageType)
        {
            var postImage = new PostImage
            {
                PostId        = postId,
                PostImageType = postImageType,
                ImageId       = imageId
            };

            _context.PostImages.Add(postImage);

            _context.SaveChanges();
        }
示例#5
0
        public static string GetPostImageUrl(AgilityContentItem blogConfig, AgilityContentItem post, PostImageType type, int width = 0, int height = 0)
        {
            string url = "";
            var    att = GetPostImage(blogConfig, post, type);

            if (att != null)
            {
                url = GetTranscodedUrl(att, width, height);
            }

            return(url);
        }
示例#6
0
        public static Attachment GetPostImage(AgilityContentItem blogConfig, AgilityContentItem post, PostImageType type)
        {
            string     listingFieldName = "ListingImageOverride";
            string     detailsFieldName = "PostImage";
            string     defaultFieldName = "DefaultPostImage";
            Attachment att = null;

            if (type.Equals(PostImageType.Listing))
            {
                att = post.GetAttachment(listingFieldName);

                if (att == null)
                {
                    att = post.GetAttachment(detailsFieldName);
                }
            }

            if (type.Equals(PostImageType.Details))
            {
                att = post.GetAttachment(detailsFieldName);
            }


            if (att == null)
            {
                //try to get attachment from default image
                att = blogConfig.GetAttachment(defaultFieldName);
            }

            return(att);
        }
示例#7
0
        public static string GetPostImageAlt(AgilityContentItem blogConfig, AgilityContentItem post, PostImageType type)
        {
            string altText = "";
            var    att     = GetPostImage(blogConfig, post, type);

            if (att != null)
            {
                altText = att.Label;
            }

            return(altText);
        }
示例#8
0
 public static bool HasPostImage(AgilityContentItem blogConfig, AgilityContentItem post, PostImageType type)
 {
     return(!IsAttachmentEmpty(GetPostImage(blogConfig, post, type)));
 }