Ejemplo n.º 1
0
        public async Task <PostWithDetailsDto> GetForReadingAsync(GetPostInput input)
        {
            var post = await _postRepository.GetPostByUrl(input.BlogId, input.Url);

            post.IncreaseReadCount();

            var postDto = ObjectMapper.Map <Post, PostWithDetailsDto>(post);

            postDto.Tags = await GetTagsOfPost(postDto.Id);

            return(postDto);
        }
Ejemplo n.º 2
0
        public async Task <PostWithDetailsDto> GetByUrlAsync(GetPostInput input)
        {
            var post = await _postRepository.GetPostByUrl(input.BlogId, input.Url);

            var postDto = ObjectMapper.Map <Post, PostWithDetailsDto>(post);

            var tagIds = (await _postTagRepository.GetListAsync()).Where(pt => pt.PostId == postDto.Id);

            var tags = await _tagRepository.GetListAsync(tagIds.Select(t => t.TagId));

            postDto.Tags = ObjectMapper.Map <List <Tag>, List <TagDto> >(tags);

            return(postDto);
        }
Ejemplo n.º 3
0
        public async Task <PostWithDetailsDto> GetForReadingAsync(GetPostInput input)
        {
            var post = await _postRepository.GetPostByUrl(input.BlogId, input.Url);

            post.IncreaseReadCount();

            var postDto = ObjectMapper.Map <Post, PostWithDetailsDto>(post);

            postDto.Tags = await GetTagsOfPost(postDto.Id);

            if (postDto.CreatorId.HasValue)
            {
                var creatorUser = await UserLookupService.FindByIdAsync(postDto.CreatorId.Value);

                postDto.Writer = ObjectMapper.Map <BlogUser, BlogUserDto>(creatorUser);
            }

            return(postDto);
        }
Ejemplo n.º 4
0
        public async Task <PostWithDetailsDto> GetByTitleAsync(GetPostInput input)
        {
            var post = await _postRepository.GetPost(input.BlogId, input.Title);

            return(ObjectMapper.Map <Post, PostWithDetailsDto>(post));
        }