public IEnumerable <PostTag> GetTagsByPostId(string id) { Guid guid = Guid.Empty; if (!Guid.TryParse(id, out guid)) { throw new Exception("Invalid guid format"); } var postTag = postTagRepository.GetTagsByPostId(guid) ?? throw new EntityNotFoundException(guid); return(postTag); }
private void LoadPostAndComments(string slug) { var data = _repo.GetSingle(slug); if (data != null) { var postId = data.Id; var postComments = _commentRepo.GetCommentsByPostId(postId); var tags = _tagRepo.GetTagsByPostId(postId); Post = _mapper.Map <PostViewModel>(data); Post.Comments = _mapper.ProjectTo <CommentViewModel>(postComments).ToList(); Post.Tags = _mapper.ProjectTo <TagViewModel>(tags).ToList(); } }
public IActionResult Get(int id) { var postTags = _postTagRepository.GetTagsByPostId(id); return(Ok(postTags)); }