Ejemplo n.º 1
0
        public GetBlogPostResponse Get(GetBlogPostRequest request)
        {
            var model = repository
                        .AsQueryable <Module.Blog.Models.BlogPost>(blogPost => blogPost.Id == request.BlogPostId)
                        .Select(blogPost => new BlogPostModel
            {
                Id             = blogPost.Id,
                Version        = blogPost.Version,
                CreatedBy      = blogPost.CreatedByUser,
                CreatedOn      = blogPost.CreatedOn,
                LastModifiedBy = blogPost.ModifiedByUser,
                LastModifiedOn = blogPost.ModifiedOn,

                BlogPostUrl             = blogPost.PageUrl,
                Title                   = blogPost.Title,
                IntroText               = blogPost.Description,
                IsPublished             = blogPost.Status == PageStatus.Published,
                PublishedOn             = blogPost.PublishedOn,
                LayoutId                = blogPost.Layout != null && !blogPost.Layout.IsDeleted ? blogPost.Layout.Id : (Guid?)null,
                MasterPageId            = blogPost.MasterPage != null && !blogPost.MasterPage.IsDeleted ? blogPost.MasterPage.Id : (Guid?)null,
                CategoryId              = blogPost.Category != null && !blogPost.Category.IsDeleted ? blogPost.Category.Id : (Guid?)null,
                CategoryName            = blogPost.Category != null && !blogPost.Category.IsDeleted ? blogPost.Category.Name : null,
                AuthorId                = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Id : (Guid?)null,
                AuthorName              = blogPost.Author != null && !blogPost.Author.IsDeleted ? blogPost.Author.Name : null,
                MainImageId             = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Id : (Guid?)null,
                MainImageUrl            = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicUrl : null,
                MainImageThumbnauilUrl  = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicThumbnailUrl : null,
                MainImageThumbnailUrl   = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.PublicThumbnailUrl : null,
                MainImageCaption        = blogPost.Image != null && !blogPost.Image.IsDeleted ? blogPost.Image.Caption : null,
                ActivationDate          = blogPost.ActivationDate,
                ExpirationDate          = blogPost.ExpirationDate,
                IsArchived              = blogPost.IsArchived,
                UseCanonicalUrl         = blogPost.UseCanonicalUrl,
                LanguageId              = blogPost.Language != null ? blogPost.Language.Id : (Guid?)null,
                LanguageCode            = blogPost.Language != null ? blogPost.Language.Code : null,
                LanguageGroupIdentifier = blogPost.LanguageGroupIdentifier
            })
                        .FirstOne();

            model.MainImageUrl           = fileUrlResolver.EnsureFullPathUrl(model.MainImageUrl);
            model.MainImageThumbnauilUrl = fileUrlResolver.EnsureFullPathUrl(model.MainImageThumbnauilUrl);
            model.MainImageThumbnailUrl  = fileUrlResolver.EnsureFullPathUrl(model.MainImageThumbnailUrl);
            LoadContentId(model);

            return(new GetBlogPostResponse
            {
                Data = model
            });
        }
Ejemplo n.º 2
0
        public GetBlogPostResponse Get(GetBlogPostRequest request)
        {
            var model = repository
                        .AsQueryable <Module.Blog.Models.BlogPost>(blogPost => blogPost.Id == request.BlogPostId)
                        .Select(blogPost => new BlogPostModel
            {
                Id             = blogPost.Id,
                Version        = blogPost.Version,
                CreatedBy      = blogPost.CreatedByUser,
                CreatedOn      = blogPost.CreatedOn,
                LastModifiedBy = blogPost.ModifiedByUser,
                LastModifiedOn = blogPost.ModifiedOn,

                BlogPostUrl            = blogPost.PageUrl,
                Title                  = blogPost.Title,
                IntroText              = blogPost.Description,
                IsPublished            = blogPost.Status == PageStatus.Published,
                PublishedOn            = blogPost.PublishedOn,
                LayoutId               = blogPost.Layout.Id,
                CategoryId             = blogPost.Category.Id,
                CategoryName           = blogPost.Category.Name,
                AuthorId               = blogPost.Author.Id,
                AuthorName             = blogPost.Author.Name,
                MainImageId            = blogPost.Image.Id,
                MainImageUrl           = blogPost.Image.PublicUrl,
                MainImageThumbnauilUrl = blogPost.Image.PublicThumbnailUrl,
                MainImageCaption       = blogPost.Image.Caption,
                ActivationDate         = blogPost.ActivationDate,
                ExpirationDate         = blogPost.ExpirationDate,
                IsArchived             = blogPost.IsArchived
            })
                        .FirstOne();

            return(new GetBlogPostResponse
            {
                Data = model
            });
        }