Esempio n. 1
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns><c>GetPageResponse</c> with page properties.</returns>
        public GetPageResponse Get(GetPageRequest request)
        {
            var query = repository.AsQueryable <PageProperties>();

            if (request.PageId.HasValue)
            {
                query = query.Where(page => page.Id == request.PageId.Value);
            }
            else
            {
                var url = urlService.FixUrl(request.PageUrl);
                query = query.Where(page => page.PageUrlHash == url.UrlHash());
            }

            var model = query
                        .Select(page => new PageModel
            {
                Id             = page.Id,
                Version        = page.Version,
                CreatedBy      = page.CreatedByUser,
                CreatedOn      = page.CreatedOn,
                LastModifiedBy = page.ModifiedByUser,
                LastModifiedOn = page.ModifiedOn,

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

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

            return(new GetPageResponse {
                Data = model
            });
        }
Esempio n. 2
0
        public GetPageResponse Get(GetPageRequest request)
        {
            var query = repository.AsQueryable <Module.Pages.Models.PageProperties>();

            if (request.PageId.HasValue)
            {
                query = query.Where(page => page.Id == request.PageId.Value);
            }
            else
            {
                var url = urlService.FixUrl(request.PageUrl);
                query = query.Where(page => page.PageUrl == url);
            }

            var model = query
                        .Select(page => new PageModel
            {
                Id             = page.Id,
                Version        = page.Version,
                CreatedBy      = page.CreatedByUser,
                CreatedOn      = page.CreatedOn,
                LastModifiedBy = page.ModifiedByUser,
                LastModifiedOn = page.ModifiedOn,

                PageUrl                = page.PageUrl,
                Title                  = page.Title,
                Description            = page.Description,
                IsPublished            = page.Status == PageStatus.Published,
                PublishedOn            = page.PublishedOn,
                LayoutId               = page.Layout.Id,
                CategoryId             = page.Category.Id,
                CategoryName           = page.Category.Name,
                MainImageId            = page.Image.Id,
                MainImageUrl           = page.Image.PublicUrl,
                MainImageThumbnauilUrl = page.Image.PublicThumbnailUrl,
                MainImageCaption       = page.Image.Caption,
                IsArchived             = page.IsArchived
            })
                        .FirstOne();

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