Example #1
0
        private CustomEntityDetails MapInitialData(CustomEntityVersion dbVersion, IExecutionContext executionContext)
        {
            var entity = new CustomEntityDetails()
            {
                CustomEntityId  = dbVersion.CustomEntity.CustomEntityId,
                UrlSlug         = dbVersion.CustomEntity.UrlSlug,
                PublishStatus   = PublishStatusMapper.FromCode(dbVersion.CustomEntity.PublishStatusCode),
                PublishDate     = dbVersion.CustomEntity.PublishDate,
                LastPublishDate = dbVersion.CustomEntity.LastPublishDate,
            };

            entity.AuditData = _auditDataMapper.MapCreateAuditData(dbVersion.CustomEntity);

            entity.LatestVersion = new CustomEntityVersionDetails()
            {
                CustomEntityVersionId = dbVersion.CustomEntityVersionId,
                Title          = dbVersion.Title,
                DisplayVersion = dbVersion.DisplayVersion,
                WorkFlowStatus = (WorkFlowStatus)dbVersion.WorkFlowStatusId
            };

            entity.LatestVersion.AuditData = _auditDataMapper.MapCreateAuditData(dbVersion);
            entity.HasDraftVersion         = entity.LatestVersion.WorkFlowStatus == WorkFlowStatus.Draft;

            return(entity);
        }
        private CustomEntityRenderSummary MapCore(CustomEntityVersion dbResult)
        {
            var entity = new CustomEntityRenderSummary()
            {
                CreateDate = DbDateTimeMapper.AsUtc(dbResult.CreateDate),
                CustomEntityDefinitionCode = dbResult.CustomEntity.CustomEntityDefinitionCode,
                CustomEntityId             = dbResult.CustomEntityId,
                CustomEntityVersionId      = dbResult.CustomEntityVersionId,
                Ordering       = dbResult.CustomEntity.Ordering,
                Title          = dbResult.Title,
                UrlSlug        = dbResult.CustomEntity.UrlSlug,
                WorkFlowStatus = (WorkFlowStatus)dbResult.WorkFlowStatusId,
                PublishDate    = DbDateTimeMapper.AsUtc(dbResult.CustomEntity.PublishDate)
            };

            entity.PublishStatus = PublishStatusMapper.FromCode(dbResult.CustomEntity.PublishStatusCode);
            entity.Model         = _customEntityDataModelMapper.Map(dbResult.CustomEntity.CustomEntityDefinitionCode, dbResult.SerializedData);

            return(entity);
        }
        private CustomEntitySummary MapBasicProperties(CustomEntityPublishStatusQuery dbStatusQuery)
        {
            var entity = new CustomEntitySummary()
            {
                AuditData = _auditDataMapper.MapUpdateAuditDataCreatorData(dbStatusQuery.CustomEntity),
                CustomEntityDefinitionCode = dbStatusQuery.CustomEntity.CustomEntityDefinitionCode,
                CustomEntityId             = dbStatusQuery.CustomEntityId,
                HasDraftVersion            = dbStatusQuery.CustomEntityVersion.WorkFlowStatusId == (int)WorkFlowStatus.Draft,
                // note that if this is not a published version, we do further checks on this later in the process
                HasPublishedVersion = dbStatusQuery.CustomEntityVersion.WorkFlowStatusId == (int)WorkFlowStatus.Published,
                PublishStatus       = PublishStatusMapper.FromCode(dbStatusQuery.CustomEntity.PublishStatusCode),
                PublishDate         = DbDateTimeMapper.AsUtc(dbStatusQuery.CustomEntity.PublishDate),
                Ordering            = dbStatusQuery.CustomEntity.Ordering,
                Title   = dbStatusQuery.CustomEntityVersion.Title,
                UrlSlug = dbStatusQuery.CustomEntity.UrlSlug
            };

            _auditDataMapper.MapUpdateAuditDataUpdaterData(entity.AuditData, dbStatusQuery.CustomEntityVersion);
            return(entity);
        }
Example #4
0
        private CustomEntityRenderDetails MapCustomEntity(CustomEntityVersion dbResult, IExecutionContext executionContext)
        {
            _permissionValidationService.EnforceCustomEntityPermission <CustomEntityReadPermission>(dbResult.CustomEntity.CustomEntityDefinitionCode, executionContext.UserContext);

            var entity = new CustomEntityRenderDetails()
            {
                CreateDate = DbDateTimeMapper.AsUtc(dbResult.CreateDate),
                CustomEntityDefinitionCode = dbResult.CustomEntity.CustomEntityDefinitionCode,
                CustomEntityId             = dbResult.CustomEntityId,
                CustomEntityVersionId      = dbResult.CustomEntityVersionId,
                Ordering       = dbResult.CustomEntity.Ordering,
                Title          = dbResult.Title,
                UrlSlug        = dbResult.CustomEntity.UrlSlug,
                WorkFlowStatus = (WorkFlowStatus)dbResult.WorkFlowStatusId,
                PublishDate    = DbDateTimeMapper.AsUtc(dbResult.CustomEntity.PublishDate)
            };

            entity.PublishStatus = PublishStatusMapper.FromCode(dbResult.CustomEntity.PublishStatusCode);
            entity.Model         = _customEntityDataModelMapper.Map(dbResult.CustomEntity.CustomEntityDefinitionCode, dbResult.SerializedData);

            return(entity);
        }
        private IQueryable <PageQueryResult> QueryPages()
        {
            var dbPages = _dbContext
                          .Pages
                          .AsNoTracking()
                          .FilterActive()
                          .Select(p => new PageQueryResult()
            {
                RoutingInfo = new PageRoute()
                {
                    PageId   = p.PageId,
                    UrlPath  = p.UrlPath,
                    PageType = (PageType)p.PageTypeId,
                    CustomEntityDefinitionCode = p.CustomEntityDefinitionCode,
                    PublishDate   = DbDateTimeMapper.AsUtc(p.PublishDate),
                    PublishStatus = PublishStatusMapper.FromCode(p.PublishStatusCode)
                },
                LocaleId        = p.LocaleId,
                PageDirectoryId = p.PageDirectoryId
            });

            return(dbPages);
        }
        private Dictionary <int, PageRoute> Map(
            List <Page> dbPages,
            Dictionary <int, IOrderedEnumerable <PageVersionQueryResult> > dbPageVersionLookup,
            Dictionary <int, PageDirectoryRoute> pageDirectories,
            Dictionary <int, PageTemplateQueryResult> templates,
            Dictionary <int, IEnumerable <PageAccessRule> > accessRuleLookup,
            ICollection <ActiveLocale> activeLocales
            )
        {
            var routes = new Dictionary <int, PageRoute>();

            foreach (var dbPage in dbPages)
            {
                var pageRoute = new PageRoute()
                {
                    PageId   = dbPage.PageId,
                    UrlPath  = dbPage.UrlPath,
                    PageType = (PageType)dbPage.PageTypeId,
                    CustomEntityDefinitionCode = dbPage.CustomEntityDefinitionCode,
                    PublishDate     = dbPage.PublishDate,
                    LastPublishDate = dbPage.LastPublishDate,
                    PublishStatus   = PublishStatusMapper.FromCode(dbPage.PublishStatusCode)
                };

                // Page directory will be null if it is inactive or has an inactive parent.
                pageRoute.PageDirectory = pageDirectories.GetOrDefault(dbPage.PageDirectoryId);
                if (pageRoute.PageDirectory == null)
                {
                    continue;
                }

                // Configure Version Info
                SetPageVersions(pageRoute, dbPageVersionLookup, templates);
                if (!pageRoute.Versions.Any())
                {
                    continue;
                }

                var accessRules = accessRuleLookup.GetOrDefault(pageRoute.PageId);
                pageRoute.AccessRuleSet = _routeAccessRuleMapper.Map(dbPage);

                // Configure Locale
                string directoryPath = null;
                if (dbPage.LocaleId.HasValue)
                {
                    pageRoute.Locale = activeLocales.FirstOrDefault(l => l.LocaleId == dbPage.LocaleId.Value);
                    EntityNotFoundException.ThrowIfNull(pageRoute.Locale, dbPage.LocaleId);

                    directoryPath = pageRoute
                                    .PageDirectory
                                    .LocaleVariations
                                    .Where(v => v.LocaleId == pageRoute.Locale.LocaleId)
                                    .Select(v => v.FullUrlPath)
                                    .FirstOrDefault();
                }

                if (directoryPath == null)
                {
                    directoryPath = pageRoute.PageDirectory.FullUrlPath;
                }

                // Set Full Path
                pageRoute.FullUrlPath = CreateFullPath(directoryPath, pageRoute.UrlPath, pageRoute.Locale);
                routes.Add(pageRoute.PageId, pageRoute);
            }
            return(routes);
        }