public async Task <IActionResult> UpdatePost(int id, JsonPatchDocument <UpdatePostDto> updatePostDto) { var post = await _repo.GetPostById(id); if (post == null) { return(NotFound()); } int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); if (post.UserId != userId) { return(Unauthorized()); } await _tagRepo.TagAmmountDecrementationUpdateByPostId(id); string description = updatePostDto.Operations.Where(x => x.path == "/description").Select(x => x.value.ToString()).FirstOrDefault(); var tags = await _tagRepo.UpdatePostTags(description, post.Id); // post.Tags = tags; var postToPatch = _mapper.Map <UpdatePostDto>(post); updatePostDto.ApplyTo(postToPatch); _mapper.Map(postToPatch, post); _repo.Edit(post); await _repo.SaveAll(); return(NoContent()); }