public async Task <IEnumerable <StoryDto> > BrowseAsync(string author = null)
        {
            var stories = await _storyRepository.BrowseAsync(author);

            return(stories.Select(x => new StoryDto
            {
                Id = x.Id,
                Author = x.Author,
                Title = x.Title,
                Tags = x.Tags ?? Enumerable.Empty <string>(),
                CreatedAt = x.CreatedAt
            }));
        }
Exemple #2
0
        public async Task <IEnumerable <StoryDto> > BrowseAsync(BrowseStories request)
        {
            Expression <Func <Story, bool> > query = story =>
                                                     (request.Author == null || story.Author.Name == request.Author) &&
                                                     (request.Title == null || story.Title.Contains(request.Title ?? string.Empty)) &&
                                                     (request.Text == null || story.Text.Value.Contains(request.Text ?? string.Empty));

            var stories = await _storyRepository.BrowseAsync(query);

            return(stories.Select(x => new StoryDto
            {
                Id = x.Id,
                Author = x.Author,
                Title = x.Title,
                Tags = x.Tags ?? Enumerable.Empty <string>(),
                CreatedAt = x.CreatedAt
            }));
        }
Exemple #3
0
 public async Task <IEnumerable <Story> > BrowseAsync(BrowseStories query)
 {
     return(await _storyRepository.BrowseAsync(query));
 }