Пример #1
0
        public IActionResult PostTag(int id)
        {
            List <PostTag> postTags = _postTagRepository.GetPostTags(id);

            if (postTags == null)
            {
                return(NotFound());
            }
            return(Ok(postTags));
        }
Пример #2
0
        public void DeletePost(int postId)
        {
            var tags = postTagRepository.GetPostTags(postId);

            postRepository.DeletePost(postId);

            postRepository.Save();

            foreach (var item in tags)
            {
                if (postTagRepository.FindNotUsedTag(item))
                {
                    tagRepository.DeleteTag(item);

                    tagRepository.Save();
                }
            }
        }
Пример #3
0
        public string FindTagsByPostId(int postId)
        {
            var tags = postTagRepository.GetPostTags(postId);

            string content = null;

            string result = null;

            if (tags.Count != 0)
            {
                foreach (var item in tags)
                {
                    var tag = tagRepository.FindTagById(item);
                    content += tag.Content + "," + " ";
                }
                result = content.Remove(content.Length - 2);
            }
            else
            {
                return(null);
            }

            return(result);
        }