public virtual async Task SetEntityTagsAsync(EntityTagSetDto input)
        {
            var definition = await TagDefinitionStore.GetTagEntityTypeDefinitionAsync(input.EntityType);

            await CheckPolicyAsync(definition.UpdatePolicy);

            await EntityTagManager.SetEntityTagsAsync(input.EntityType, input.EntityId, input.Tags);
        }
Example #2
0
        public async Task SetEntityTagsAsync(EntityTagSetDto input)
        {
            var definition = await _tagDefinitionStore.GetTagEntityTypeDefinitionsAsync(input.EntityType);

            await CheckPolicyAsync(definition.UpdatePolicy);

            var existingTags = await _tagRepository.GetAllRelatedTagsAsync(input.EntityType, input.EntityId, CurrentTenant?.Id);

            var deletedTags = existingTags.Where(x => !input.Tags.Contains(x.Name)).ToList();
            var addedTags   = input.Tags.Where(x => !existingTags.Any(a => a.Name == x));

            await _entityTagRepository.DeleteManyAsync(deletedTags.Select(s => s.Id).ToArray());

            foreach (var addedTag in addedTags)
            {
                var tag = await _tagManager.GetOrAddAsync(input.EntityType, addedTag, CurrentTenant?.Id);

                await _entityTagManager.AddTagToEntityAsync(tag.Id, input.EntityType, input.EntityId, CurrentTenant?.Id);
            }
        }
Example #3
0
 public Task SetEntityTagsAsync(EntityTagSetDto input)
 {
     return(EntityTagAdminAppService.SetEntityTagsAsync(input));
 }