/// <summary> /// To the model. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static PageRoute ToModel(this PageRouteDto value) { PageRoute result = new PageRoute(); value.CopyToModel(result); return(result); }
/// <summary> /// Copies the properties from another PageRoute object to this PageRoute object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this PageRoute target, PageRoute source) { target.IsSystem = source.IsSystem; target.PageId = source.PageId; target.Route = source.Route; target.Id = source.Id; target.Guid = source.Guid; }
/// <summary> /// Clones this PageRoute object to a new PageRoute object /// </summary> /// <param name="source">The source.</param> /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param> /// <returns></returns> public static PageRoute Clone(this PageRoute source, bool deepCopy) { if (deepCopy) { return(source.Clone() as PageRoute); } else { var target = new PageRoute(); target.CopyPropertiesFrom(source); return(target); } }
/// <summary> /// Copies the properties from another PageRoute object to this PageRoute object /// </summary> /// <param name="target">The target.</param> /// <param name="source">The source.</param> public static void CopyPropertiesFrom(this PageRoute target, PageRoute source) { target.Id = source.Id; target.IsSystem = source.IsSystem; target.PageId = source.PageId; target.Route = source.Route; target.CreatedDateTime = source.CreatedDateTime; target.ModifiedDateTime = source.ModifiedDateTime; target.CreatedByPersonAliasId = source.CreatedByPersonAliasId; target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId; target.Guid = source.Guid; target.ForeignId = source.ForeignId; }
/// <summary> /// Sets the value. /// </summary> /// <param name="pageRoute">The page route.</param> public void SetValue(Rock.Model.PageRoute pageRoute) { if (pageRoute != null) { Rock.Model.Page page = pageRoute.Page; PageRouteId = pageRoute.Id; ItemId = page.Id.ToString(); var parentPageIds = new List <string>(); var parentPage = page.ParentPage; while (parentPage != null) { if (!parentPageIds.Contains(parentPage.Id.ToString())) { parentPageIds.Insert(0, parentPage.Id.ToString()); } else { // infinite recursion break; } parentPage = parentPage.ParentPage; } InitialItemParentIds = parentPageIds.AsDelimited(","); if (pageRoute.Id != 0) { // PageRoute is selected, so show the Page and its PageRoute and don't show the PageRoute picker ItemName = page.InternalName + " (" + pageRoute.Route + ")"; _rblSelectPageRoute.Visible = false; _btnShowPageRoutePicker.Style[HtmlTextWriterStyle.Display] = "none"; } else { // Only a Page is selected, so show PageRoutePicker button if it has page routes ItemName = page.InternalName; PageRouteId = null; // Update PageRoutePicker control values _rblSelectPageRoute.Items.Clear(); _rblSelectPageRoute.Visible = page.PageRoutes.Any(); if (page.PageRoutes.Count > 0) { foreach (var item in page.PageRoutes) { _rblSelectPageRoute.Items.Add(new ListItem(item.Route, item.Id.ToString())); } } if (_rblSelectPageRoute.Items.Count > 0) { _btnShowPageRoutePicker.Style[HtmlTextWriterStyle.Display] = ""; } else { _btnShowPageRoutePicker.Style[HtmlTextWriterStyle.Display] = "none"; } if (_rblSelectPageRoute.Items.Count == 1) { _btnShowPageRoutePicker.Text = "( 1 route exists )"; } else { _btnShowPageRoutePicker.Text = "(" + _rblSelectPageRoute.Items.Count + " routes exist )"; } } } else { ItemId = Rock.Constants.None.IdValue; ItemName = Rock.Constants.None.TextHtml; PageRouteId = null; _rblSelectPageRoute.Visible = false; _btnShowPageRoutePicker.Style[HtmlTextWriterStyle.Display] = "none"; } }
/// <summary> /// Instantiates a new DTO object from the entity /// </summary> /// <param name="pageRoute"></param> public PageRouteDto(PageRoute pageRoute) { CopyFromModel(pageRoute); }
/// <summary> /// To the dto. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static PageRouteDto ToDto(this PageRoute value) { return(new PageRouteDto(value)); }