Ejemplo n.º 1
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

                   ));
        }