コード例 #1
0
 public VehicleModelWithFilterCountAsync(VehicleModelParams queryParams)
     : base(x =>
            (string.IsNullOrEmpty(queryParams.Search) || x.VehicleModelName.ToLower().Contains(queryParams.Search)) &&
            (!queryParams.VehicleBrandId.HasValue || x.VehicleBrandId == queryParams.VehicleBrandId) &&
            (!queryParams.VehicleCategoryId.HasValue || x.VehicleCategoryId == queryParams.VehicleCategoryId)
            )
 {
 }
コード例 #2
0
 public VehicleModelWithBrandAndCategory(VehicleModelParams queryParams)
     : base(x =>
            (
                string.IsNullOrEmpty(queryParams.Search) ||
                x.VehicleModelName.ToLower().Contains(queryParams.Search) ||
                x.VehicleBrands.BrandName.ToLower().Contains(queryParams.Search)
            ) &&
            (!queryParams.VehicleBrandId.HasValue || x.VehicleBrandId == queryParams.VehicleBrandId) &&
            (!queryParams.VehicleCategoryId.HasValue || x.VehicleCategoryId == queryParams.VehicleCategoryId)
            )
 {
     AddInclude(x => x.VehicleBrands);
     AddInclude(x => x.VehicleCategories);
     AddOrderBy(x => x.VehicleModelName);
     ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize);
 }
コード例 #3
0
        //[SecuredOperation("Sudo,VehicleAnnounceOptions.All", Priority = 1)]
        public async Task <Pagination <VehicleModelForReturnDto> > GetListAsync(VehicleModelParams vehicleModelParams)
        {
            var spec             = new VehicleModelWithBrandAndCategory(vehicleModelParams);
            var vehicleModelList = await vehicleModelDal.ListEntityWithSpecAsync(spec);

            var countSpec  = new VehicleModelWithFilterCountAsync(vehicleModelParams);
            var totalCount = await vehicleModelDal.CountAsync(countSpec);

            if (vehicleModelList == null)
            {
                throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound });
            }

            var data = mapper.Map <List <VehicleModel>, List <VehicleModelForReturnDto> >(vehicleModelList);

            return(new Pagination <VehicleModelForReturnDto>
                   (
                       vehicleModelParams.PageIndex,
                       vehicleModelParams.PageSize,
                       totalCount,
                       data

                   ));
        }
コード例 #4
0
 public async Task <ActionResult <Pagination <VehicleModelForReturnDto> > > List([FromQuery] VehicleModelParams queryParams)
 {
     return(await vehicleModelService.GetListAsync(queryParams));
 }