public IActionResult Put(int id, Post post)
        {
            if (id != post.Id)
            {
                return(BadRequest());
            }
            //delete the tags associated with the post
            List <PostTag> postTags = _postTagRepository.GetByPostId(id);

            foreach (PostTag postTag in postTags)
            {
                _postTagRepository.Delete(postTag.Id);
            }

            _postRepository.Update(post);
            return(NoContent());
        }
Exemplo n.º 2
0
        public IActionResult GetByPostTags(int id)
        {
            var postTags = _postTagRepository.GetByPostId(id);

            if (postTags == null)

            {
                return(NotFound());
            }
            return(Ok(postTags));
        }