Ejemplo n.º 1
0
        public async Task <PaginatedItemsResult <GetTasksByProjectIdItemResult> > Handle(GetTasksByProjectId request, CancellationToken cancellationToken)
        {
            var projectTasks = _dbContext.Tasks.AsNoTracking()
                               .Where(x => x.ProjectId == request.ProjectId)
                               .OrderByDescending(x => x.CreatedDate);

            var result = await _paginationService.PaginateAsync <GetTasksByProjectIdItemResult>(projectTasks, request.PageIndex,
                                                                                                request.PageSize, cancellationToken);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <Result <PaginatedItemsResult <GetProjectResult> > > HandleAsync(GetProjects queryModel)
        {
            var baseQuery = _dbContext.Set <Project>().AsNoTracking();

            var result = await _paginationService.PaginateAsync <GetProjectResult>
                         (
                baseQuery,
                queryModel.PageIndex,
                queryModel.PageSize
                         );

            return(Result.Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <PaginatedItemsResult <SearchProjectsItemResult> > Handle(SearchProjects request,
                                                                                    CancellationToken cancellationToken)
        {
            var projects = _dbContext.Projects
                           .AsNoTracking()
                           .Where(x => x.Title.ToLower().Contains(request.Value.ToLower()) || x.Description.ToLower().Contains(request.Value.ToLower()))
                           .OrderByDescending(x => x.CreatedDate);

            var result = await _paginationService.PaginateAsync <SearchProjectsItemResult>(projects, request.PageIndex,
                                                                                           request.PageSize, cancellationToken);

            return(result);
        }