示例#1
0
        public async Task <ItemsPage <Airplane> > SearchAirplanesAsync(AirplaneFilter filter)
        {
            AirplaneFilterEntity filterDal = _mapper.Map <AirplaneFilterEntity>(filter);

            ItemsPageEntity <AirplaneEntity> airplanesDal =
                await _airplaneRepository.SearchAirplanesAsync(filterDal);

            ItemsPage <Airplane> airplanes = _mapper.Map <ItemsPage <Airplane> >(airplanesDal);

            return(airplanes);
        }
示例#2
0
        public async Task <ActionResult> GetAsync(
            string nameFilter,
            int?minCarryingKg,
            int?maxCarryingKg,
            int?minSeatCount,
            int?maxSeatCount,
            int?currentPage,
            int?pageLimit
            )
        {
            currentPage ??= _paginationSettings.DefaultPage;
            pageLimit ??= _paginationSettings.DefaultPageSize;

            if (pageLimit > _paginationSettings.MaxPageLimit)
            {
                return(BadRequest());
            }

            BlItemsPage airplanesBl;

            if (!string.IsNullOrEmpty(nameFilter) ||
                minCarryingKg != null ||
                maxCarryingKg != null ||
                minSeatCount != null ||
                maxSeatCount != null
                )
            {
                AirplaneFilter airplaneFilter = new AirplaneFilter(
                    nameFilter,
                    minCarryingKg,
                    maxCarryingKg,
                    minSeatCount,
                    maxSeatCount,
                    currentPage.Value,
                    pageLimit.Value);

                BlAirplaneFilter airplaneFilterBl = _mapper.Map <BlAirplaneFilter>(airplaneFilter);

                airplanesBl = await _airplaneService.SearchAirplanesAsync(airplaneFilterBl);
            }
            else
            {
                airplanesBl = await _airplaneService.GetAllAsync(currentPage.Value, pageLimit.Value);
            }

            ItemsPage <Airplane> airplanes = _mapper.Map <ItemsPage <Airplane> >(airplanesBl);

            return(Ok(airplanes));
        }