private async Task SeedTagsAsync() { foreach (var tag in _cmsKitTestData.Content_1_Tags) { var tagEntity = await _tagManager.InsertAsync(_guidGenerator.Create(), _cmsKitTestData.Content_1_EntityType, tag); await _entityTagRepository.InsertAsync(new EntityTag(tagEntity.Id, _cmsKitTestData.Content_1_EntityId)); } foreach (var tag in _cmsKitTestData.Content_2_Tags) { var tagEntity = await _tagManager.InsertAsync(_guidGenerator.Create(), _cmsKitTestData.Content_2_EntityType, tag); await _entityTagRepository.InsertAsync(new EntityTag(tagEntity.Id, _cmsKitTestData.Content_2_EntityId)); } }
public async Task <EntityTag> AddTagToEntityAsync( [NotNull] Guid tagId, [NotNull] string entityType, [NotNull] string entityId, [CanBeNull] Guid?tenantId = null, CancellationToken cancellationToken = default) { if (!await _tagDefinitionStore.IsDefinedAsync(entityType)) { throw new EntityNotTaggableException(entityType); } var entityTag = new EntityTag(tagId, entityId, tenantId); return(await _entityTagRepository.InsertAsync(entityTag, cancellationToken : cancellationToken)); }