예제 #1
0
        private void addTags(string[] Tags, int postId)
        {
            List <PostTag> postTags = new List <PostTag>();

            foreach (var tag in Tags)
            {
                var assignTag = _tagRepository.GetByName(tag);
                if (assignTag is null)
                {
                    assignTag = new Tag {
                        name = tag
                    };
                    _tagRepository.Add(assignTag);
                }

                postTags.Add(new PostTag {
                    TagId = assignTag.id, PostId = postId
                });
            }

            _postTagRepository.BulkInsert(postTags);
        }