public async Task <List <TodoDto> > Handle(GetTodosQuery request, CancellationToken cancellationToken) { return(await _context.Todos .Where(x => request.Query == null || ( x.Content.Contains(request.Query) || x.Email.Contains(request.Query) ) ) .OrderBy(x => x.Date) .ProjectTo <TodoDto>(_mapper.ConfigurationProvider) .ToListAsync()); }
public Task <List <Todo> > Handle(GetTodosQuery request, CancellationToken cancellationToken) { var todos = _context.Todos.Select(t => Mapper.Map <Todo>(t, null)).ToList(); return(Task.FromResult(todos)); }