public VehicleBrandWithFilterForCountAsyncSpecification(VehicleBrandParams queryParams) : base(x => (string.IsNullOrEmpty(queryParams.Search) || x.BrandName.ToLower().Contains(queryParams.Search) ) && (!queryParams.VehicleCategoryId.HasValue || x.VehicleCategoryId == queryParams.VehicleCategoryId) ) { }
public VehicleBrandWithVehicleCategorySpecification(VehicleBrandParams queryParams) : base(x => ( string.IsNullOrEmpty(queryParams.Search) || x.BrandName.ToLower().Contains(queryParams.Search) ) && (!queryParams.VehicleCategoryId.HasValue || x.VehicleCategoryId == queryParams.VehicleCategoryId) ) { AddInclude(x => x.VehicleCategories); AddOrderBy(x => x.BrandName); ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize); }
//[SecuredOperation("Sudo,VehicleAnnounceOptions.All", Priority = 1)] public async Task <Pagination <VehicleBrandForReturnDto> > GetListAsync(VehicleBrandParams vehicleBrandParams) { var spec = new VehicleBrandWithVehicleCategorySpecification(vehicleBrandParams); var vehicleBrandList = await vehicleBrandDal.ListEntityWithSpecAsync(spec); var countSpec = new VehicleBrandWithFilterForCountAsyncSpecification(vehicleBrandParams); var totalCount = await vehicleBrandDal.CountAsync(countSpec); if (vehicleBrandList == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } var data = mapper.Map <List <VehicleBrand>, List <VehicleBrandForReturnDto> >(vehicleBrandList); return(new Pagination <VehicleBrandForReturnDto> ( vehicleBrandParams.PageIndex, vehicleBrandParams.PageSize, totalCount, data )); }
public async Task <ActionResult <Pagination <VehicleBrandForReturnDto> > > List([FromQuery] VehicleBrandParams vehicleBrandParams) { return(await vehicleBrandService.GetListAsync(vehicleBrandParams)); }