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); }
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); }
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); }
public async Task <PostWithDetailsDto> GetByTitleAsync(GetPostInput input) { var post = await _postRepository.GetPost(input.BlogId, input.Title); return(ObjectMapper.Map <Post, PostWithDetailsDto>(post)); }