private IQueryable <TodoItem> ApplyPaging(IQueryable <TodoItem> query, GetItemsGrid request)
        {
            if (request.PageSize > 0)
            {
                return(query.Skip(request.PageIndex * request.PageSize)
                       .Take(request.PageSize)
                       .OrderBy(x => x.Created));
            }

            return(query);
        }
        public async Task <IEnumerable <ItemsGridDto> > Handle(GetItemsGrid request, CancellationToken cancellationToken)
        {
            var query = _context.TodoItems.AsQueryable();

            query = ApplyPaging(query, request);

            return(await query.Select(i => new ItemsGridDto()
            {
                ItemId = i.Id,
                ListId = i.ListId,
                Title = i.Title,
                Done = i.Done,
                ListName = i.List.Title
            }).ToListAsync(cancellationToken));
        }