Esempio n. 1
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);
        }
Esempio n. 2
0
        public IQueryable <Project> SearchProject(SearchProjects options)
        {
            var project_ = context_
                           .Set <Project>()
                           .AsQueryable();

            if (options == null)
            {
                return(null);
            }

            if (!string.IsNullOrWhiteSpace(options.Title))
            {
                project_ = project_.Where(p =>
                                          p.Tittle == options.Title);
            }

            if (options.Id <= 0)
            {
                project_ = project_.Where(p =>
                                          p.id == options.Id);
            }
            return(project_);
        }
        public async Task <IActionResult> SearchProjects([FromQuery] SearchProjects query)
        {
            var result = await _mediator.Send(query);

            return(Ok(result));
        }