/// <summary> /// Locates and returns the correct templates for a block if it a custom template /// assigned, otherwise null is returned. /// </summary> /// <param name="pageBlock">An unmapped database block to locate the template for.</param> /// <param name="blockType">The block type associated with the block in which to look for the template.</param> public PageBlockTypeTemplateSummary GetCustomTemplate(IEntityVersionPageBlock pageBlock, PageBlockTypeSummary blockType) { if (pageBlock == null) { throw new ArgumentNullException(nameof(pageBlock)); } if (blockType == null) { throw new ArgumentNullException(nameof(blockType)); } if (!pageBlock.PageBlockTypeTemplateId.HasValue) { return(null); } var template = blockType .Templates .FirstOrDefault(t => t.PageBlockTypeTemplateId == pageBlock.PageBlockTypeTemplateId); Debug.Assert(template != null, string.Format("The block template with id {0} could not be found for {1} {2}", pageBlock.PageBlockTypeTemplateId, pageBlock.GetType().Name, pageBlock.GetVersionBlockId())); return(template); }
/// <summary> /// Locates and returns the correct templates for a block if it a custom template /// assigned, otherwise null is returned. /// </summary> /// <param name="pageBlock">An unmapped database block to locate the template for.</param> /// <param name="blockType">The block type associated with the block in which to look for the template.</param> public PageBlockTypeTemplateSummary GetCustomTemplate(IEntityVersionPageBlock pageBlock, PageBlockTypeSummary blockType) { if (pageBlock == null) { throw new ArgumentNullException(nameof(pageBlock)); } if (blockType == null) { throw new ArgumentNullException(nameof(blockType)); } if (!pageBlock.PageBlockTypeTemplateId.HasValue) { return(null); } var template = blockType .Templates .FirstOrDefault(t => t.PageBlockTypeTemplateId == pageBlock.PageBlockTypeTemplateId); if (template == null) { _logger.LogDebug("The block template with id {PageBlockTypeTemplateId} could not be found for {PageBlockType} {VersionBlockId}", pageBlock.PageBlockTypeTemplateId, pageBlock.GetType().Name, pageBlock.GetVersionBlockId()); } return(template); }