コード例 #1
0
        public async Task <List <TourDto> > Handle(GetToursQuery request, CancellationToken cancellationToken)
        {
            var pipeline = _pipelineBuilder
                           .WithNode(new AgencyPipelineNode(request.Agencies))
                           .WithNode(new CategoryPipelineNode(request.Categories))
                           .WithNode(new NamePipelineNode(request.Name))
                           .WithNode(new PriceRangePipelineNode(request.MinPrice, request.MaxPrice))
                           .WithNode(new TimeOfTheYearPipelineNode(request.TimeOfTheYear))
                           .WithNode(new DestinationPointPipelineNode(request.DestinationPointId))
                           .Execute();

            var filter     = pipeline.Execute();
            var sortOption = _sortOptionFactory.Create <Tour>(request.SortOption);

            var tours = await _toursRepository.FindAllAsync(
                filter,
                sortOption.Expression,
                sortOption.Direction,
                GetSkipValue(request.PageNumber, request.PageSize),
                request.PageSize);

            var toursDto = _mapper.Map <List <Tour>, List <TourDto> >(tours);

            return(toursDto);
        }