Esempio n. 1
0
        public IEnumerable <FlightAvailabilityResponse> ListAvailability(FlightAvailabiltyRequest req)
        {
            var result = from eachFlight in _dbCtx.Flights.AsNoTracking()
                         join eachBooking in _dbCtx.Bookings.AsNoTracking() on eachFlight.Id equals eachBooking.FlightId
                         join eachFromCity in _dbCtx.Cities.AsNoTracking() on eachFlight.DepartingCityId equals eachFromCity.Id
                         join eachToCity in _dbCtx.Cities.AsNoTracking() on eachFlight.ArrivalCityId equals eachToCity.Id
                         where eachFromCity.CityName == req.CityFrom &&
                         eachToCity.CityName == req.CityTo &&
                         eachBooking.TravelDay >= req.StartDate &&
                         eachBooking.TravelDay <= req.EndDate
                         select new { eachFlight, eachBooking } into joined
            group joined by new { joined.eachFlight.FlightName, joined.eachBooking.TravelDay } into grouped
                         select new FlightAvailabilityResponse()
            {
                FlightName     = grouped.FirstOrDefault().eachFlight.FlightName,
                TravelDay      = grouped.FirstOrDefault().eachBooking.TravelDay,
                AvailableSeats = grouped.FirstOrDefault().eachFlight.PassengerCapacity.Value - grouped.Count()
            };

            return(result);
        }
Esempio n. 2
0
 public bool CheckAvaliablity([FromBody] FlightAvailabiltyRequest req) => _flightRep.CheckAvailability(req);
Esempio n. 3
0
 public bool CheckAvailability(FlightAvailabiltyRequest req) =>
 ListAvailability(req).Any(a => a.AvailableSeats >= req.Pax);
Esempio n. 4
0
 public IEnumerable <FlightAvailabilityResponse> ListAvailablity([FromBody] FlightAvailabiltyRequest req) => _flightRep.ListAvailability(req);