public string MakeUrl(PageRoute pageRoute, CustomEntityRoute entityRoute) { Condition.Requires(pageRoute).IsNotNull(); Condition.Requires(entityRoute).IsNotNull(); return(pageRoute.FullPath.Replace(RouteFormat, entityRoute.UrlSlug)); }
private PageRoutingInfo ToRoutingInfo(PageRoute pageRoute, CustomEntityRoute customEntityRoute = null, ICustomEntityRoutingRule rule = null) { return(new PageRoutingInfo() { PageRoute = pageRoute, CustomEntityRoute = customEntityRoute, CustomEntityRouteRule = rule }); }
public string MakeUrl(PageRoute pageRoute, CustomEntityRoute entityRoute) { Condition.Requires(pageRoute).IsNotNull(); Condition.Requires(entityRoute).IsNotNull(); return(pageRoute.FullPath .Replace("{Id}", entityRoute.CustomEntityId.ToString()) .Replace("{UrlSlug}", entityRoute.UrlSlug)); }
/// <summary> /// Maps an EF CustomEntity record from the db into a CustomEntityRoute object. If the /// db record is null then null is returned. /// </summary> /// <param name="dbCustomEntity">CustomEntity record from the database.</param> /// <param name="locale">Locale to map to the object.</param> public CustomEntityRoute Map( CustomEntity dbCustomEntity, ActiveLocale locale ) { if (dbCustomEntity == null) { throw new ArgumentNullException(nameof(dbCustomEntity)); } if (dbCustomEntity.CustomEntityVersions == null) { throw new ArgumentNullException(nameof(dbCustomEntity.CustomEntityVersions)); } var route = new CustomEntityRoute() { CustomEntityDefinitionCode = dbCustomEntity.CustomEntityDefinitionCode, CustomEntityId = dbCustomEntity.CustomEntityId, UrlSlug = dbCustomEntity.UrlSlug, Locale = locale, PublishDate = DbDateTimeMapper.AsUtc(dbCustomEntity.PublishDate), PublishStatus = dbCustomEntity.PublishStatusCode == PublishStatusCode.Published ? PublishStatus.Published : PublishStatus.Unpublished, Ordering = dbCustomEntity.Ordering }; bool hasLatestPublishVersion = false; route.Versions = new List <CustomEntityVersionRoute>(); foreach (var dbVersion in dbCustomEntity .CustomEntityVersions .OrderByLatest()) { var version = new CustomEntityVersionRoute() { CreateDate = DbDateTimeMapper.AsUtc(dbVersion.CreateDate), Title = dbVersion.Title, VersionId = dbVersion.CustomEntityVersionId, WorkFlowStatus = (WorkFlowStatus)dbVersion.WorkFlowStatusId }; if (!hasLatestPublishVersion && version.WorkFlowStatus == WorkFlowStatus.Published) { version.IsLatestPublishedVersion = true; hasLatestPublishVersion = true; } route.Versions.Add(version); } route.HasDraftVersion = route.Versions.Any(v => v.WorkFlowStatus == WorkFlowStatus.Draft); route.HasPublishedVersion = route.Versions.Any(v => v.WorkFlowStatus == WorkFlowStatus.Published); return(route); }
/// <summary> /// Transforms the routing specified routing information into a full, relative url. /// </summary> /// <param name="pageRoute">The matched page route for the url</param> /// <param name="entityRoute">The matched custom entity route for the url</param> /// <returns>Full, relative url</returns> public string MakeUrl(PageRoute pageRoute, CustomEntityRoute entityRoute) { if (pageRoute == null) { throw new ArgumentNullException(nameof(pageRoute)); } if (entityRoute == null) { throw new ArgumentNullException(nameof(entityRoute)); } return(pageRoute.FullPath.Replace(RouteFormat, entityRoute.UrlSlug)); }
/// <summary> /// Transforms the routing specified routing information into a full, relative url. /// </summary> /// <param name="pageRoute">The matched page route for the url</param> /// <param name="entityRoute">The matched custom entity route for the url</param> /// <returns>Full, relative url</returns> public string MakeUrl(PageRoute pageRoute, CustomEntityRoute entityRoute) { if (pageRoute == null) { throw new ArgumentNullException(nameof(pageRoute)); } if (entityRoute == null) { throw new ArgumentNullException(nameof(entityRoute)); } return(pageRoute.FullUrlPath .Replace("{Id}", entityRoute.CustomEntityId.ToString()) .Replace("{UrlSlug}", entityRoute.UrlSlug)); }
/// <summary> /// Determines if the page is published at this moment in time, /// checking the page and custom entity (if available) published status, the publish date /// and checking to make sure there is a published version. /// </summary> public bool IsPublished() { if (PageRoute == null) { throw new InvalidOperationException($"Cannot call {nameof(IsPublished)} if the {nameof(PageRoute)} property is null."); } var isPublished = PageRoute.IsPublished(); if (isPublished && CustomEntityRoute != null) { isPublished = CustomEntityRoute.IsPublished(); } return(isPublished); }
/// <summary> /// Maps an EF CustomEntity record from the db into a CustomEntityRoute object. If the /// db record is null then null is returned. /// </summary> /// <param name="dbCustomEntity">CustomEntity record from the database.</param> /// <param name="locale">Locale to map to the object.</param> /// <param name="routingDataProperties">Collection of data properties to map to the routing parameters collection.</param> public CustomEntityRoute Map( CustomEntity dbCustomEntity, ActiveLocale locale ) { if (dbCustomEntity == null) { throw new ArgumentNullException(nameof(dbCustomEntity)); } var route = new CustomEntityRoute() { CustomEntityDefinitionCode = dbCustomEntity.CustomEntityDefinitionCode, CustomEntityId = dbCustomEntity.CustomEntityId, UrlSlug = dbCustomEntity.UrlSlug, Locale = locale, PublishDate = DbDateTimeMapper.AsUtc(dbCustomEntity.PublishDate), PublishStatus = dbCustomEntity.PublishStatusCode == PublishStatusCode.Published ? PublishStatus.Published : PublishStatus.Unpublished, Ordering = dbCustomEntity.Ordering }; var versions = new List <CustomEntityVersionRoute>(); route.Versions = versions; foreach (var dbVersion in dbCustomEntity.CustomEntityVersions) { var version = new CustomEntityVersionRoute() { CreateDate = DbDateTimeMapper.AsUtc(dbVersion.CreateDate), Title = dbVersion.Title, VersionId = dbVersion.CustomEntityVersionId, WorkFlowStatus = (WorkFlowStatus)dbVersion.WorkFlowStatusId }; versions.Add(version); } return(route); }
public CustomEntityRouteDataBuilderParameter( CustomEntityRoute customEntityRoute, CustomEntityVersionRoute customEntityVersionRoute, TDataModel dataModel ) { if (customEntityRoute == null) { throw new ArgumentNullException(nameof(customEntityRoute)); } if (customEntityVersionRoute == null) { throw new ArgumentNullException(nameof(customEntityVersionRoute)); } if (dataModel == null) { throw new ArgumentNullException(nameof(dataModel)); } _customEntityRoute = customEntityRoute; _customEntityVersionRoute = customEntityVersionRoute; _dataModel = dataModel; }