コード例 #1
0
        public async Task <IEnumerable <Trip> > GetAllAsync(FindTripInfoViewModel info)
        {
            var parametersTrips = _context.Trips
                                  .Include(t => t.TransportType)
                                  .Include(t => t.ArrivalPlace).ThenInclude(p => p.Country)
                                  .Include(t => t.DeparturePlace).ThenInclude(p => p.Country)
                                  .Where(t => t.DeparturePlaceId == info.DepartureId &&
                                         t.ArrivalPlaceId == info.ArrivalId && t.DepartureTime.Date == info.DepartureDate.Date);

            if (info.TransportTypeId.HasValue)
            {
                parametersTrips = parametersTrips.Where(t => info.TransportTypeId.Value == t.TransportTypeId);
            }

            if (info.ArrivalDate.HasValue)
            {
                parametersTrips = parametersTrips.Where(t => info.ArrivalDate.Value.Date == t.ArrivalTime.Date);
            }

            return(await parametersTrips.ToListAsync());
        }
コード例 #2
0
 public async Task <IEnumerable <Trip> > GetAsync(FindTripInfoViewModel info) =>
 await _unitOfWork.TripRepository.GetAllAsync(info);