示例#1
0
        public Task <PageResponse <PriceSubmission> > GetList(long?gasStationId, FuelType?fuelTypes, long?createdByUserId,
                                                              int pageNumber = RequestDefaults.PageNumber, int pageSize = RequestDefaults.PageSize)
        {
            var types = fuelTypes ?? FuelType.All;
            var query = new GetPriceSubmissions(gasStationId, types, createdByUserId, pageNumber, pageSize);

            return(priceSubmissionsService.GetList(query));
        }
        public Task <PageResponse <PriceSubmission> > GetList(GetPriceSubmissions query)
        {
            var dbQuery = dbContext.PriceSubmissions.Include(x => x.Ratings).AsQueryable();

            if (query.FuelTypes != FuelType.All)
            {
                dbQuery = dbQuery.Where(x => query.FuelTypes.HasFlag(x.FuelType));
            }

            if (query.CreatedByUserId.HasValue)
            {
                dbQuery = dbQuery.Where(x => x.CreatedByUserId == query.CreatedByUserId.Value);
            }

            if (query.GasStationId.HasValue)
            {
                dbQuery = dbQuery.Where(x => x.GasStationId == query.GasStationId.Value);
            }

            return(dbQuery
                   .OrderByDescending(x => x.LastModified)
                   .PickPageAsync(query.PageNumber, query.PageSize, x => x.ToContract()));
        }