private static void EnsurePositionsAreEqual(PositionDescriptor destPosition, PositionDescriptor sourcePosition) { if (sourcePosition.Template == null) { throw new InvalidOperationException("Source content position has not link with template"); } if (destPosition.Template != null && destPosition.Template.Id != sourcePosition.Template.Id) { throw new InvalidOperationException($"Positions has different linked templates ({sourcePosition.Template.Id} in source and {destPosition.Template.Id} in destination)"); } }
private async Task ClonePositionLinkAsync(PositionDescriptor sourcePosition, PositionDescriptor destPosition) { var templateId = sourcePosition.Template?.Id; if (templateId.HasValue) { if (destPosition?.Template?.Id == templateId) { _logger.LogInformation("Link between position {id} and template {template} already exists, skip linking", sourcePosition.Id, templateId.Value); return; } _logger.LogInformation("Creating link between position {id} and template {template}", sourcePosition.Id, templateId.Value); await DestRestClient.CreatePositionTemplateLinkAsync(sourcePosition.Id.ToString(), templateId.Value.ToString()); } }