Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }