public async Task <DataTable> BookingsForSpecificTripDatabase(TripBookingRequest uIRequest) { string query = $"SELECT t4.ShortName ,COUNT(t4.ShortName) AS Bookings FROM TripProducts t1 JOIN PassengerSegments t2 ON t1.Id=t2.TripProductId JOIN AirSegments t3 ON t3.TripProductId=t1.Id Join Airlines t4 on t4.AirlineCode = t3.MarketingAirlineCode where t1.ProductType='Air' AND t2.BookingStatus='Purchased' AND t1.ModifiedDate between '{uIRequest.FromDate}' and '{uIRequest.ToDate}' and t3.DepartAirportCode='{uIRequest.DepartAirportCode}' and t3.ArriveAirportCode='{uIRequest.ArrivalAirportCode}' group by t4.ShortName;"; DataTable dataTable = await QueryExecuter(query); return(dataTable); }
public async Task <IActionResult> GetBookingsForSpecificTrip([FromQuery] string fromDate, string toDate, string departAirportCode, string arrivalAirportCode) { TripBookingRequest uiRequest = new TripBookingRequest { FromDate = fromDate, ToDate = toDate, ArrivalAirportCode = arrivalAirportCode, DepartAirportCode = departAirportCode }; return(Ok(await webApiServiceProvider.BookingsForSpecificTripService(uiRequest))); }
public async Task <List <BookingsForSpecificTrip> > BookingsForSpecificTripService(TripBookingRequest uIRequest) { string result = null; string redisKey = "BookingInfoForTrip" + uIRequest.ArrivalAirportCode + uIRequest.FromDate + uIRequest.ToDate + uIRequest.ArrivalAirportCode; result = _cache.Get(redisKey); if (result == null) { DataTable dataTable = await _sqlDatabase.BookingsForSpecificTripDatabase(uIRequest); result = _airTranslator.BookingsForSpecificTripTranslator(dataTable); _cache.Add(redisKey, result); } List <BookingsForSpecificTrip> bookingsForSpecificTrips = JsonConvert.DeserializeObject <List <BookingsForSpecificTrip> >(result); return(bookingsForSpecificTrips); }