Beispiel #1
0
        public void Delete(int postId)
        {
            var tags = _postTagRepository.GetBy(postId);
            var post = _postRepository.Get()
                       .FirstOrDefault(p => p.Id == postId);

            if (post == null)
            {
                return;
            }

            foreach (var tag in tags)
            {
                _postTagRepository.Delete(tag);
            }

            var postModel = new PostModel
            {
                Id      = post.Id,
                Deleted = true
            };

            _elasticService.IndexData(postModel); // Delete the document in ES
            _postRepository.Delete(post);
        }
        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());
        }
Beispiel #3
0
        public void Delete(int postId)
        {
            var tags = _postTagRepository.GetBy(postId);
            var post = _postRepository.Get()
                       .FirstOrDefault(p => p.Id == postId);

            if (post == null)
            {
                return;
            }

            foreach (var tag in tags)
            {
                _postTagRepository.Delete(tag);
            }

            _elasticService.Delete(post.Id);
            _postRepository.Delete(post);
        }
Beispiel #4
0
 public IActionResult Delete(int id)
 {
     _postTagRepository.Delete(id);
     return(NoContent());
 }