public async Task <IActionResult> TagsUpdate([FromBody] CmsPostWebHookApiModel model)
        {
            if (model == null)
            {
                return(BadRequest("delete model empty or null."));
            }

            var postId = model.post_id;

            if (postId <= 0)
            {
                return(BadRequest($"post id null. model.post_id: {postId}"));
            }

            if (model.post.post_status == "trash")
            {
                var removeSuccessful = await _tagRepository.Delete(postId);

                if (!removeSuccessful)
                {
                    _logger.LogError("Failed to delete tag with id: {PostId} in elasticsearch.", postId);
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to delete tag."));
                }
                return(NoContent());
            }

            var cmsTag = await _cmsApiProxy.GetTag(postId);

            var elasticTag = await MapToElasticModel(cmsTag);

            bool successful;
            var  tag = await _tagRepository.Get(postId);

            if (tag == null)
            {
                successful = await _tagRepository.Insert(new List <TagElasticModel> {
                    elasticTag
                });

                if (!successful)
                {
                    _logger.LogError("Failed to insert tag with id:{PostId} in elasticsearch.", postId);
                    return(BadRequest("Failed to insert tag."));
                }

                _logger.LogInformation("Inserted tag with id {PostId} to elasticsearch successfully.", postId);

                return(Created(elasticTag.Id.ToString(), elasticTag));
            }

            successful = await _tagRepository.Update(elasticTag);

            if (!successful)
            {
                _logger.LogError("Failed to update tag with id:{PostId} in elasticsearch.", postId);
                return(BadRequest("Failed to update tag."));
            }

            _logger.LogInformation("Updated tag with id {PostId} to elasticsearch successfully.", postId);

            return(Ok());
        }