コード例 #1
0
ファイル: PostTagsServices.cs プロジェクト: Aodai/TechBytes
        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);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        public IActionResult Get(int id)
        {
            var postTags = _postTagRepository.GetTagsByPostId(id);

            return(Ok(postTags));
        }