Esempio n. 1
0
        /// <summary>
        /// Saves the slug
        /// </summary>
        /// <param name="contentChannelItemId">The content channel item identifier.</param>
        /// <param name="slug">The slug.</param>
        /// <param name="contentChannelItemSlugId">The content channel item slug identifier.</param>
        /// <returns></returns>
        public ContentChannelItemSlug SaveSlug(int contentChannelItemId, string slug, int?contentChannelItemSlugId)
        {
            var uniqueSlug = this.GetUniqueContentSlug(slug, contentChannelItemSlugId, contentChannelItemId);

            if (uniqueSlug.IsNullOrWhiteSpace())
            {
                return(null);
            }

            var rockContext = ( RockContext )this.Context;

            ContentChannelItemSlug contentChannelItemSlug = null;

            if (contentChannelItemSlugId.HasValue)
            {
                contentChannelItemSlug = this.Get(contentChannelItemSlugId.Value);
            }
            else
            {
                contentChannelItemSlug = new ContentChannelItemSlug();
                contentChannelItemSlug.ContentChannelItemId = contentChannelItemId;
                this.Add(contentChannelItemSlug);
            }

            contentChannelItemSlug.Slug = uniqueSlug;

            rockContext.SaveChanges();
            return(contentChannelItemSlug);
        }
Esempio n. 2
0
 /// <summary>
 /// Clones this ContentChannelItemSlug object to a new ContentChannelItemSlug 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 ContentChannelItemSlug Clone(this ContentChannelItemSlug source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as ContentChannelItemSlug);
     }
     else
     {
         var target = new ContentChannelItemSlug();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Copies the properties from another ContentChannelItemSlug object to this ContentChannelItemSlug object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this ContentChannelItemSlug target, ContentChannelItemSlug source)
 {
     target.Id = source.Id;
     target.ContentChannelItemId = source.ContentChannelItemId;
     target.ForeignGuid          = source.ForeignGuid;
     target.ForeignKey           = source.ForeignKey;
     target.IsPrimary            = source.IsPrimary;
     target.Slug                    = source.Slug;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }