private void CloneHtmlContent( Dictionary<Guid, Guid> blockGuidDictionary, RockContext rockContext, int? currentPersonAliasId = null )
{
var htmlContentService = new HtmlContentService( rockContext );
var blockService = new BlockService( rockContext );
Dictionary<Guid, int> blockIntDictionary = blockService.Queryable()
.Where( p => blockGuidDictionary.Keys.Contains( p.Guid ) || blockGuidDictionary.Values.Contains( p.Guid ) )
.ToDictionary( p => p.Guid, p => p.Id );
var htmlContents = htmlContentService.Queryable().Where( a =>
blockIntDictionary.Values.Contains( a.BlockId ) )
.ToList();
foreach ( var htmlContent in htmlContents )
{
var newHtmlContent = htmlContent.Clone( false );
newHtmlContent.CreatedByPersonAlias = null;
newHtmlContent.CreatedByPersonAliasId = currentPersonAliasId;
newHtmlContent.CreatedDateTime = RockDateTime.Now;
newHtmlContent.ModifiedByPersonAlias = null;
newHtmlContent.ModifiedByPersonAliasId = currentPersonAliasId;
newHtmlContent.ModifiedDateTime = RockDateTime.Now;
newHtmlContent.Id = 0;
newHtmlContent.Guid = Guid.NewGuid();
newHtmlContent.BlockId = blockIntDictionary[blockGuidDictionary[blockIntDictionary.Where( d => d.Value == htmlContent.BlockId ).FirstOrDefault().Key]];
htmlContentService.Add( newHtmlContent );
}
rockContext.SaveChanges();
}